Coding with Jesse

Working around "Click to activate and use this control"

August 29th, 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.


Interested in web development? Subscribe to my newsletter!

Comments

1 . Frode on September 12nd, 2006

Frode

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 on September 20th, 2006

JS

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 on September 25th, 2006

Steeve

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

4 . Rick on December 18th, 2006

Rick

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 on December 27th, 2006

aRchiTektUrA

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

6 . Jesse Skinner on December 27th, 2006

Jesse Skinner

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 on December 28th, 2006

Andres

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

Voila!

8 . Pax.be on December 28th, 2006

Pax.be

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 on January 8th, 2007

john myles

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 on January 11st, 2007

Konrad

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 on February 16th, 2007

Josef

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 on March 14th, 2007

PCLIVE

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

13 . David (Raspu) on March 17th, 2007

David (Raspu)

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 on April 4th, 2007

Rokkster

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 on April 16th, 2007

Andy

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

16 . Mike on April 18th, 2007

Mike

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 on April 23rd, 2007

funta

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

http://jactivating.sourceforge.net

18 . Erik on April 27th, 2007

Erik

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

19 . Rapid on May 10th, 2007

Rapid

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 on May 15th, 2007

Ryan

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 on June 1st, 2007

Zelaza

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 on June 1st, 2007

Zelaza

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 on June 1st, 2007

Jesse Skinner

@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 on June 14th, 2007

danjal

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 on June 18th, 2007

Gary

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 on June 18th, 2007

Gary Vance

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 on June 27th, 2007

asnara

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 on June 30th, 2007

SirHuckleberry

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 on July 27th, 2007

Jordan Ambra

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 on August 3rd, 2007

Prabhakar

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 on August 25th, 2007

Janne Granström

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

32 . Aaron L on September 25th, 2007

Aaron L

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 on October 19th, 2007

Hendrik

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 on February 14th, 2008

akulaarip

Thanks man,

Your code sure save my day.

35 . sam on March 14th, 2008

sam

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

36 . Alex on April 2nd, 2008

Alex

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 on April 2nd, 2008

Alex

JORDAN,

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

Thanks

38 . Melissa A. on June 3rd, 2008

Melissa A.

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 on June 3rd, 2008

Jesse Skinner

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

40 . Melissa A. on June 3rd, 2008

Melissa A.

It's at:

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

41 . Melissa A. on June 3rd, 2008

Melissa A.

Oh, and none of the other links work.

42 . Jesse Skinner on June 3rd, 2008

Jesse Skinner

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

43 . Melissa A. on June 3rd, 2008

Melissa A.

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

44 . Rob on June 4th, 2008

Rob

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

45 . Melissa A. on June 4th, 2008

Melissa A.

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

46 . naruto on July 20th, 2008

naruto

very useful , thx so much.

47 . nilesh on December 15th, 2008

nilesh

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

thanks friends...

48 . Doug on January 5th, 2009

Doug

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

Thanks

49 . Borislav Georgiev on March 24th, 2009

Borislav Georgiev

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 on April 23rd, 2009

Phileas

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

Phil.

51 . Jeff Morrision on September 19th, 2009

Jeff Morrision

intresting and it ad worth to the reality

52 . Mark on October 1st, 2009

Mark

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 on July 9th, 2010

Vlad

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

54 . Matt on August 12nd, 2010

Matt

Top stuff, this worked great!

55 . Kevin on March 8th, 2011

Kevin

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 on August 24th, 2011

jeeef

Cool article

57 . naruto on August 24th, 2011

naruto

I will share this article in my language Can I?

58 . Jesse Skinner on August 24th, 2011

Jesse Skinner

@naruto - sure go ahead.

Comments are closed, but I'd still love to hear your thoughts.