1. Home
  2. Computing & Technology
  3. Animation

WorkAround for the Flash/ ActiveX Activation Issue in IE6+

By Adrien-Luc Sanders, About.com

Although I'm a dedicated Firefox user (memory leaks and all), I still test my web designs across various browsers and platforms to ensure cross-browser compatibility. One problem that I've encountered in Internet Explorer is that any time I include a Flash animation in the page, initially the embedded SWF is framed by a grey bounding box that tells me that I have to click on the control to activate it. This is an IE-only limitation involving how ActiveX scripting is displayed; normally I don't find it an issue, since often I avoid using Flash components for anything other than decoration/enhancement so that I don't lose people with Flash disabled because they can't find the navigation. However, sometimes I have to find a workaround to remove that extra (and annoying) step to make that content clickable, and for that workaround I use dynActiveX.js.

What is dynActiveX.js?
dynActiveX.js is a JavaScript developed by user fproductions and posted to the Adobe Flash forum/newsgroup. The JavaScript overrides the ActiveX problem so that Flash movies are automatically activated in Internet Explorer.

How can I get dynActiveX.js?
Fairly easily. You'll have to create the file yourself; you can also Google for it, but I tend not to trust downloading scripts from unknown sources. If you'd like to just create your own, open a new NotePad file and copy the following code into it:

//dynActiveX.js is credit to Flash forum user fpproductions
// When the page loads:
window.onload = function(){
if (document.getElementsByTagName) {
// Get all the tags of type object in the page.
var objs = document.getElementsByTagName("object");
for (i=0; i<objs.length; i++) {
// Get the HTML content of each object tag
// and replace it with itself.
objs[i].outerHTML = objs[i].outerHTML;
}
}
}
// When the page unloads:
window.onunload = function() {
if (document.getElementsByTagName) {
//Get all the tags of type object in the page.
var objs = document.getElementsByTagName("object");
for (i=0; i<objs.length; i++) {
// Clear out the HTML content of each object tag
// to prevent an IE memory leak issue.
objs[i].outerHTML = "";
}
}
}

Okay, the credit tagline is my addition, but the rest of it should be copied word-for-word. In your NotePad file, click File->Save As and save the file as dynActiveX.js.

Okay, so now that I have the JavaScript, how do I use it?
First you need to add code to the file containing your Flash file, telling it to look for the external JavaScript file and make sure that its contents are executed as the page loads. Look for the <head> tag in your HTML; after the <head> tag and before the </head> tag, paste the following code:

<!--[if gte IE 6]>
<script src="dynActiveX.js"></script>
<![endif]-->

All that does is check the browser version and, if it's Internet Explorer 6 or higher, run dynActiveX.js to remove the control activation problem.

When that's finished, upload both your web page and your dynActiveX.js file to the same directory on your web server. You should be able to reload your page and display Flash movies without problems.

If you liked this JavaScript workaround for Flash, you may want to learn more about JS from About.com's JavaScript Guide, Stephen Chapman.

Explore Animation
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. WorkAround for the Flash/ ActiveX Activation Issue in IE6+

©2009 About.com, a part of The New York Times Company.

All rights reserved.