• Working around "Click to activate and use this control"

    Aug 29 2006

    As you may likely be aware, the latest versions of Internet Explorer and Opera have decided not to give Eolas any money for their patent. Instead, users are forced to click on plugins (movies, sound, Flash and Java applets). In other words, anything inside object, embed or applet tags.

    Thankfully, there is a way around this. Microsoft has documented some workarounds. I've put together a solution here that works in Opera as well:

    // only execute code if 'getElementsByTagName' and 'outerHTML' are supported
    if (document.getElementsByTagName && document.body.outerHTML) {
        // repeat code for each affected tag
        var tags = ['object','embed','applet'];
    
        for (var i in tags) {
            // get all elements with tag
            var objs = document.getElementsByTagName(tags[i]);
    
            for (var j=0;j < objs.length;j++) {
                var obj = objs.item(j);
    
                // find param tags within object
                var params = obj.getElementsByTagName('param');
                var inner = '';
    
                // if there are params, but param tags can't be found within innerHTML
                if (params.length && !/<param/i.test(obj.innerHTML))
                    // add all param tags to 'inner' string
                    for (var x=0;x < params.length;x++)
                        inner += params.item(x).outerHTML;
    
                // put 'inner' string with param tags in the middle of the outerHTML
                obj.outerHTML = obj.outerHTML.replace('>', '>' + inner);
            }
        }
    }
    

    Download this script here.

    The code only executes on browsers which support getElementsByTagName and outerHTML (Internet Explorer, Opera and Safari - but not Firefox). It gets around the patent by dynamically "altering" the outerHTML (even though nothing is changed from the original HTML). But beware: you need to put it in an external JavaScript file to work.

    To do this, simply put the code into a file. Let's say it's called eolas.js. Then put this line anywhere after all the object, embed or applet tags:

    <script type="text/javascript" src="eolas.js"></script>
    

    Alternatively, you can keep the script tags out of the body by wrapping the code in eolas.js in a function, then use my addDOMLoadEvent function to run the Eolas script once the page has loaded. So if you change eolas.js like so:

    function fixEolas() {
        // same code above
    }
    

    then just put this in the <head> of the page:

    <script type="text/javascript" src="eolas.js"></script>
    <script type="text/javascript" src="adddomloadevent.js"></script>
    <script type="text/javascript">
    addDOMLoadEvent(fixEolas);
    </script>
    

    Unfortunately, the JavaScript file will be downloaded unnecessarily for users who don't use Internet Explorer or Opera. But if Safari or other browsers implement the same thing, this JavaScript code will already be in place to fix it.

    And there you have it. Three cheers for horrible software patents!

    Update: The code I posted before breaks objects with <param> tags in Internet Explorer. It turns out that outerHTML doesn't contain <param> tags, so extra work needs to be done to make sure they stay intact. I've updated the script accordingly.

  • Comments

    1. Frode at 5:53pm on September 12, 2006

    Nice try, but there are two problems with this solution. First of all MSIE seems to see the wrong number of param for each object if their are more than one object present in the document.

    This is not a problem if the param FlashVar is not used but the second problem is that MSIE seems to ignore the value of this param and return is at an empty string.

    This means that <param name="FlashVars" value="url=http://something" /> is returned as <param name="FlashVars" value="" />. This is possible to fix with only one object, but with more objects in the document it is a bit harder. I am trying to fix it to night and may have a solution in the morning.

    2. JS at 2:28pm on September 20, 2006

    The easiest solution I have found for flashvars is just to put in the url of the src "flash.swf?url=..."

    But there are a lot of other solutions at http://activecontent.blogspot.com/

    3. Steeve at 9:08am on September 25, 2006

    I get a message that the page contains errors in IE 6 windows me , if I refresh its fine. it

    4. Rick at 12:29am on December 18, 2006

    I tried a few solutions and found this one, applied with your addDOM... script to be one of the easiest to implement. Thanks!

    5. aRchiTektUrA at 3:42pm on December 27, 2006

    Do you suggest to wait till a this legal non-sense is over or implement fixes? How long will it take?

    6. Jesse Skinner at 3:46pm on December 27, 2006

    I'm not sure this legal non-sense will ever be over until the patent expires, and I have no idea when that will be (10 years or more?) I think we're stuck having to do this workaround for the meantime...

    7. Andres at 4:32pm on December 28, 2006

    This behavor was introduced as an automatic windows upgrade, search for KB925454 and uninstall it.

    Voila!

    8. Pax.be at 7:13pm on December 28, 2006

    Hi Jesse,

    Congratulation for your solutions!

    I tried both and I opted for the function (the 2nd solution), because without AddDom (the first solution) Internet Explorer keeps loading (see at the Windows flag) until you choose another page.

    The second solution works perfect on my computer and also on my hosted website ... except for the main page!

    I searched and tried other scripts from Internet, nothing works for the main page. Any idee?

    9. john myles at 11:55am on January 8, 2007

    NOT being a javascript expert but nevertheless use javascript in my private web pages, where can I determine how this affect me and find a full description of what to do and why?

    10. Konrad at 5:31pm on January 11, 2007

    Hi Jesse,

    Thanks for your solution, I was looking for something that was cross browser and would work for a java applet.

    However, when loading the page it appear for a second and then the applet goes grey. Any idea what could be happening here? the preview site is at http://ruddi-47003-001.dsvr.co.uk/clocktower-restaurant/virtual-tours/bar.php

    Thanks!

    Konrad

    11. Josef at 6:17am on February 16, 2007

    Thanks - best solution I've found so far - works with applets aswell but the applet params are not set right so it needs some tuning for that to work...

    12. PCLIVE at 12:02pm on March 14, 2007

    It looks like KB918899 also includes the problem causing update.  Hmmm.  Maybe someone should make a list of these.

    13. David (Raspu) at 12:58am on March 17, 2007

    Hi Jesse!

    I'm developing a similar script since 2006 (but i didn't know yours). I would like your opinion about this [http://jactivating.sourceforge.net]

    David :D

    14. Rokkster at 3:59pm on April 4, 2007

    I'm confused - the version of Dreamweaver I'm using (8) has a solution for this out of the box. The moment I open a page with embedded Flash it offers to alter the code and provides a js script to upload - and the activate to click link has gone. Maybe this was an upgrade at some point - but it's definitely there.

    15. Andy at 7:47pm on April 16, 2007

    I can hack Opera browser to bypass "Click here to activate and use this control"?

    16. Mike at 2:06pm on April 18, 2007

    This is one of the only easy workarounds I've found that actually works to remove the click to activate, but has anyone else noticed that it kills animated gif's and know what I can do about that?

    17. funta at 5:28am on April 23, 2007

    The one from David mentioned above worked best for me with applet/params etc..

    http://jactivating.sourceforge.net

    18. Erik at 1:55pm on April 27, 2007

    Hi, I've found another way:
    http://www.mix-fx.com/flash-prompt.htm

    19. Rapid at 4:42am on May 10, 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/

    20. Ryan at 12:05pm on May 15, 2007

    Is there a way to activate the object if you load it dynamically using javascript? I load a PDF on a click of a link.

    This is the javascript I use to do so:

    var embed = document.createElement("embed");
    embed.setAttribute("src", pdfURL);
    embed.setAttribute("width", "800");
    embed.setAttribute("height", "600");
           
    theDiv.appendChild(embed);


    I have tried putting Jesse's code into a js file, wrapping it around a function, then calling the function after my javascript code, but that doesn't seem to work.

    Any ideas?

    21. Zelaza at 12:00am on June 1, 2007

    Hi Jesse,

    I tried using eola.js with adddomloadevent.js and it seems to work, BUT the little green loading ring on IE7 continues to spin all the time until I unload the page (as if the page never finished loading).

    Is this something to be concerned about?

    And why does it happen - I've noticed it happens with several of these Eola workarounds.

    Thanks.

    22. Zelaza at 12:06am on June 1, 2007

    Jesse,

    Another question.

    Is there any reason I couldn't use your first method but put the script in the <head> and add a "defer" as in:

    <script type="text/javascript" src="eolas.js" defer="defer"></script>

    Would this accomplish the same thing as adddomloadevent?

    23. Jesse Skinner at 10:16am on June 1, 2007

    @Zelaza - I'm not sure why it would cause the page to hang...

    As for using 'defer', well that's actually partially how adddomloadevent works actually. But defer only works in IE, so the script takes care of doing the same in Safari, Firefox and Opera.

    24. danjal at 2:20pm on June 14, 2007

    Has any one a work around regarding IE not stop loading the page ??????

    Please let me know - if there is anyone cool out there that could fix that....

    25. Gary at 6:02am on June 18, 2007

    Hi,

    Has anyone tried to use this with more than one flash element on a page? 

    I've just tried it, and the script works fine for the first element, but subsequent elements whilst activated correctly,  show the first flash animation again.

    Otherwise... top solution - very easy to use - thanks!

    Thanks.

    26. Gary Vance at 6:25am on June 18, 2007

    re my previous message, changing this section of the code:

      for (var x=0;x < params.length;x++)
          inner += params.item(x).outerHTML;

    to this:

        inner += params.item(j).outerHTML; 

    sees to do the trick.  I appreciate there may be problems in other implementations, but for me this works nicely.

    Thanks.

    27. asnara at 3:00am on June 27, 2007

    Based on this solution:
    http://erwin.ried.cl/?modo=visor&elemento=230

    "Click to activate and use..." automatic remover:
    http://d01.megashares.com/?d01=2bdb329

    28. SirHuckleberry at 2:32pm on June 30, 2007

    It seems this solution doesn't work with Java Applets and IE7. The Applet could not be displayed and if you klick on it the IE will crash. ;(

    29. Jordan Ambra at 5:41am on July 27, 2007

    I found a fun way to get rid of the IE loading bar after objects are replaced.

    Replace this line:
    obj.outerHTML = obj.outerHTML.replace('>', '>' + inner);

    With these lines:
    var strNewHTML = obj.outerHTML.replace('>', '>' + inner);
    var objReplace = document.createElement("object");
    obj.replaceNode(objReplace);
    objReplace.outerHTML = strNewHTML;


    It looks like the replaceNode() method cancels any HTTP requests that the applet/object/Flash has open at the time, which makes the loading bar go away. Then, it will load as it should when you set the outerHTML.

    30. Prabhakar at 10:45am on August 3, 2007

    I used the above code, i have four applets in a page, first i tried to use the same code as u given, i am getting blank innr strings, then

    if (params.length && !/<param/i.test(obj.innerHTML)) - I modified this condition to,

    if (params.length ) - now i am getting the inner HTMl output, but i am getting first applet code only !!! Help me

    31. Janne Granström at 9:11pm on August 25, 2007

    Well.. is there any client base solution.. like some plugin for IE itself than some server scripts?

    32. Aaron L at 4:38pm on September 25, 2007

    have been trying to implement this and other similar scripts into my pager with no success...

    when I use it in simple form, it works...but what I need to do is bring up an object that is loaded using .innerHTML change command. (In other words, when my page first comes up, there is no object, then, when the user clicks on something, it does an .innerHTML on a absolute positioned DIV that "pops-up" the embedded object...and, in IE, I get the good ole "Click to activate..." crap.

    There must be something I can do in my case, which I admit is a bit different than usual.

    Thanks folks!

    33. Hendrik at 9:19am on October 19, 2007

    You can go to the following url where you can download a fix. It is very easy to implement. And based on a Java Script that you place on your ftp site.

    http://www.helewix.co.za/forum/viewtopic.php?f=13&t=8

    34. akulaarip at 2:27am on February 14, 2008

    Thanks man,

    Your code sure save my day.

    35. sam at 9:26am on March 14, 2008

    Hi Jesse,
    when I add eolas.js windows media player stop playing.why? any ideas.
    thanks

    36. Alex at 7:29am on April 2, 2008

    I use a lot of flash banners on my site that users click on to be taken to casino landing pages. This is the only solution I've found that consistently works on every page without interfering with the html of each page. I used your addDOMloadevent.js script and wrapped the code as a function in an external javascript page and it worked perfectly. Thank you for this life-saving piece of code. Genius!

    37. Alex at 8:04am on April 2, 2008

    JORDAN,

    I had the same problem with the page still loading. Your code works superbly.

    Thanks

    38. Melissa A. at 5:55pm on June 3, 2008

    I copy and pasted your code exactly, and in IE 7 it still shows the damn click here box.

    I thought IE 7 shouldn't be showing the box at all in the first place, but I guess I was mistaken... I thought maybe I was using a version older than 6, so when I went to check I was certainly surprised to see 7!

    I've even tried what Adobe recommends on their site, and I still can't get rid of the box....

    39. Jesse Skinner at 5:56pm on June 3, 2008

    @Melissa - would you be willing to share a URL to the page where it doesn't work?

    40. Melissa A. at 6:09pm on June 3, 2008

    It's at:

    http://www.mach1global.com/flashtest/eolas.htm

    41. Melissa A. at 6:11pm on June 3, 2008

    Oh, and none of the other links work.

    42. Jesse Skinner at 6:13pm on June 3, 2008

    The site works fine for me in IE7. How is it for anyone else?

    43. Melissa A. at 6:14pm on June 3, 2008

    Well that's good.  How does it work in IE6 for you... I wonder why mine doesn't work. o_0

    44. Rob at 10:47pm on June 4, 2008

    http://activecontent.blogspot.com/#114553164480870609 worked for us as these other fixes didn't.

    45. Melissa A. at 11:27pm on June 4, 2008

    Thanks Rob, I'll try that when I get into work tomorrow! :)

    46. naruto at 7:41am on July 20, 2008

    very useful , thx so much.

    47. nilesh at 4:35am on December 15, 2008

    this is not done in flash cs4...
    is there any solution to remove this problem in cs4 version of flash.

    thanks friends...

    48. Doug at 11:26am on January 5, 2009

    Your solution is the only one I could find that works out of the box for me.

    Thanks

    49. Borislav Georgiev at 10:23am on March 24, 2009

    I found very silly solution to the problem with Opera - when i added this line: <script type="text/javascript" src="/styles/eolas.js"></script>
    but forgot to upload the eolas.js file everything worked fine. When I uploaded it - it stopped working.

    50. Phileas at 2:17pm on April 23, 2009

    Thanks a lot for the fix. Really helped me out.

    Phil.

    51. Jeff Morrision at 7:29am on September 19, 2009

    intresting and it ad worth to the reality

    52. Mark at 5:15am on October 1, 2009

    f*** microsoft... this isn't working - could it be because I'm using ie8? Tried several other approaches too, but still getting that stupid messagebar... any ideas?

    53. Vlad at 11:59am on July 9, 2010

    "Click to activate and use this control" fix for Opera 10
    http://www.youtube.com/watch?v=7Ic9Gr8sHW8

    54. Matt at 9:01am on August 12, 2010

    Top stuff, this worked great!

    55. Kevin at 2:02am on March 8, 2011

    Thanks for creating and sharing this solution.  It's the best I've found so far.  I like that it doesn't require one to reformat all of the object code.

    56. jeeef at 10:16am on August 24, 2011

    Cool article

    57. naruto at 2:50pm on August 24, 2011

    I will share this article in my language Can I?

    58. Jesse Skinner at 2:53pm on August 24, 2011

    @naruto - sure go ahead.

    Commenting is now closed. Come find me on Twitter.