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);
}
}
}
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.
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.
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/
I get a message that the page contains errors in IE 6 windows me , if I refresh its fine. it
I tried a few solutions and found this one, applied with your addDOM... script to be one of the easiest to implement. Thanks!
Do you suggest to wait till a this legal non-sense is over or implement fixes? How long will it take?
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...
This behavor was introduced as an automatic windows upgrade, search for KB925454 and uninstall it.
Voila!
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?
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?
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
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...
It looks like KB918899 also includes the problem causing update. Hmmm. Maybe someone should make a list of these.
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
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.
I can hack Opera browser to bypass "Click here to activate and use this control"?
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?
The one from David mentioned above worked best for me with applet/params etc..
http://jactivating.sourceforge.net
Hi, I've found another way:
http://www.mix-fx.com/flash-prompt.htm
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/
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?
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.
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?
@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.
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....
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.
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.
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
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. ;(
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.
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
Well.. is there any client base solution.. like some plugin for IE itself than some server scripts?
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!
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
Hi Jesse,
when I add eolas.js windows media player stop playing.why? any ideas.
thanks
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!
JORDAN,
I had the same problem with the page still loading. Your code works superbly.
Thanks
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....
@Melissa - would you be willing to share a URL to the page where it doesn't work?
The site works fine for me in IE7. How is it for anyone else?
Well that's good. How does it work in IE6 for you... I wonder why mine doesn't work. o_0
http://activecontent.blogspot.com/#114553164480870609 worked for us as these other fixes didn't.
Thanks Rob, I'll try that when I get into work tomorrow! :)
this is not done in flash cs4...
is there any solution to remove this problem in cs4 version of flash.
thanks friends...
Your solution is the only one I could find that works out of the box for me.
Thanks
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.
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?