Fix the ”Click to activate” Flash content in IE

Aug 7, 2006

In the good name of internet security, Microsoft added a feature in Internet Explorer that disables automatic activation of objects. All objects in an HTML <object> tag is affected and that includes Java applets and Adobe Flash content. That means you manually have to click a Flash movie in order to activate it before you can use it.

If you have a Flash menu on your website, then the visitors have to click twice in order to navigate – one to activate and one to click the actual link. You don’t want that!

Lucky for us, JavaScript can solve the problem quite easily. Just add this script to the <head> section of your HTML document.

<script type=”text/javascript”>
function ActivateFlash()
{
   var objects = document.getElementsByTagName("object");
   for (var i = 0; i < objects.length; i++)
   {
      objects[i].outerHTML = objects[i].outerHTML;
   }
}
</script>

And call the function from the <body> tag like this:

<body onload=”ActivateFlash();”>

Of course, this is not a good solution, because you probably already have an included JavaScript file and don’t want scripts mixed with your HTML. The obvious choice is to add the script to your .js file, and then add an event handler, so you don’t need to call it with an onload-command from the <body> tag.

Copy the function into your .js file and add the event handler line in top of that file:

window.onload = ActivateFlash

function ActivateFlash()
{
   var objects = document.getElementsByTagName("object");
   for (var i = 0; i < objects.length; i++)
   {
      objects[i].outerHTML = objects[i].outerHTML;
   } 
}

By doing it this way, you don’t have to pollute you’re HTML with JavaScript in order to eliminate the Flash activation in Internet Explorer.

* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Comments (4) -

Eric
Eric
8/9/2006 1:06:26 AM #

It wasn't in the name of good security that this was added; it was to comply with the Eolas patent ruling.

 Bryan Peters
Bryan Peters
8/9/2006 2:42:01 AM #

I've been using SWFObject for a while now for all my Flash needs.  Check it out!

http://blog.deconcept.com/swfobject/

 Jan Schreuder
Jan Schreuder
8/9/2006 10:20:52 AM #

Isn't this the same problem as with ActiveX components? I had something similar with the Outlook webmail client our company uses. As it turns out, Microsoft has released a patch which counteracts their own patch which is responsible for that behaviour. I have some links on this issue in this blogpost: bloggingabout.net/.../12164.aspx

 Cam Soper
Cam Soper
8/11/2006 7:55:53 PM #

Another option is to not embed the object with an object tag in HTML.  Use JavaScript to do it dynamically.  See:   http://tinyurl.com/aovax

Comments are closed

About the author

Mads Kristensen

Mads Kristensen
Program Manager at the Microsoft Web Platform team and founder of BlogEngine.NET.

More...

Month List

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.