Discover & Rate New Music Check out ChartVote. Promote the music you like.


IE ‘Click to Activate’ Flash Fix

Since Microsoft lost the patent battle between Eolas, IE has been required to display ActiveX plugins differently. This change now requires a user to click on the plugin for the user can interact with it. The plugin will still animate/play automatically, but user interaction is disabled until clicked.

A quick method of getting around this annoying problem is to write the flash to your HTML from an external Javascript file.

Example
- demo.htm

HTML:
  1. <title>IE Flash Fix Demo</title>
  2. <script language="javascript" src="flashfix.js">
  3. </head>
  4.  
  5. <div id="flash_container"></div>
  6.  
  7. <script language="javascript">
  8.  writeFlash('flash_container');
  9. </script>
  10.  
  11. </body>
  12. </html>

- flashfix.js

JavaScript:
  1. function writeFlash(id) {
  2.     document.getElementById(id).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='200' height='200' id='myflash' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='mymovie.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='mymovie.swf' quality='high' bgcolor='#ffffff' width='200' height='200' name='mymovie' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
  3. }

You can view a working demo Here.

Another solution is to use SWFObject formely known as flashObject. SWFObject has alot of great features for embedding flash into your HTML including the ability to detect what version of flash a user's browser is running.

Check SWFObject out here


16 Comments

  1. Alex Hillman on October 13th, 2006

    it should be noted, that this doesnt ALWAYS work.

    in fact, none of the documented fixes work all the time.

    I've got a very heavy flash/html hybrid site i'm building, and every once in a while...the click to activate comes back. it seems to be when IE is left idle for 15+ minutes.

    Ive spoken with the developer of SwfObject, and he says that its a bug/feature of IE, NOT the swfobject embed.

    go figure. thanks MS.

  2. Noah Winecoff on October 13th, 2006

    Thanks for the heads on up on that Alex. On the site I'm developing I am dynamically adding and removing the flash many times so the Click to Activate came up EVERY time which was so annoying. At least this will stop it most of the time. Thanks for the comment!

  3. Alex Hillman on October 13th, 2006

    im doing the same thing...using javascript + swfobject to create kinda like a sIFR for images...png transparency to be specific.

    check it out on my blog. http://dangerouslyawesome.com/png2swf

    updated files/documentation are on the way, once this project is done.

  4. Michael Frost on November 18th, 2006

    I have tried using SWFObject to remove the rotten dorred line but I'm having problems because i have 2 flash objects in the page - i have removed it from the nav bar but not the animation. Can you help? Thanks

  5. Sarah on January 9th, 2007

    Michael, make sure you give the divs you're writing to different ID's and change this parameter in the swf object call. Then you should be able to easily use swfobject for two embeds on one page.

  6. Jay on February 20th, 2007

    having trouble here, first of all i think you need to close your tag in the head.
    Second, the http:// is causing everything in my js file to be commented after the //. Its a good idea though, I see how it works.

  7. Patrice on April 8th, 2007

    Hi,

    Big thank for this craftiness.

    My problem is now fixed.

    For a best use of the javascript function, you can use a timer.

    Example:

    window.setTimeout("active_flash()",50);
    //Fix (object div, object flash)
    function active_flash()
    {
    fix('flash_object', 'my_object.swf');
    }

    Good Day,

    Patrice

  8. Rapid on May 10th, 2007

    Take a look at this solution with just 2 lines of code.

    this site which has a solution to flash objects 'click here to activate control' not seen it before anywhere and it works on blogs as well.

    http://clickheretoactivate.blogspot.com/

  9. guruCrypt on July 9th, 2007

    If you've got 101 of these like the site I was working on and just happen to have a script that you use globally across the site - stick this in the onload or in script tags at the bottom of your page(s)

    //fix flash BS
    fla=document.getElementsByTagName('object');
    for (i=0; i

  10. Mark on August 6th, 2007

    Yes, problem easily solved by mozilla, Firefox works fine with flash, IE not so much. My problem is that my school does not have firefox. So a certain website in flash does the click to activate, but when I do so it does not activate.....

  11. indre on November 1st, 2007

    so how to remove flash control active? please help... i have tried a lot of solutions, but it didn't work.. :(

  12. Vinh on November 6th, 2007

    so how to remove flash control active? please help... i have tried a lot of solutions, but it didn't work..
    The same here!! Help Us please

  13. Alex on November 18th, 2007

    There is a problem with this method if the user does not allow javascript, the div where the movie should be will be empty. The method I use is as follows:

    HTML File:

    IE Flash Fix Demo

    "

    External js File:
    obj=document.getElementsByTagName('object');
    for (var i=0; i<obj.length; ++i)
    obj[i].outerHTML=obj[i].outerHTML;

    This js code must be in an external file to work, and will remove the click to activate message for all flash objects on the page. If the user does not allow javascript, the movie will still be written, but have the click to activate message.

    Alex

  14. Mickey on January 28th, 2008

    Doesn't seem to work in Netscape

  15. Paul Tierney on March 6th, 2008

    This solution does not transfer flashvars

  16. Confusioner on March 10th, 2008

    There is only %100 solution for this:

    include doms with AJAX. that fixes the problems.

Leave a Reply

RSS Feed



Recommended Sites