A Potential Solution to the Eolas Flash Woes - The Object Replacement Method
Wednesday 19 April 2006 @ 8:04 am
Filed under:

There are a number of solutions out there for the limitation that Microsoft just put into place to deal with the Microsoft-Eolas plug-in patent dispute. The ones that I have seen (e.g: Flashobject) are nice but involve changing how you publish your Flash files and embed them into the HTML. I was thinking, it is possible to rewrite the HTML on the fly with JavaScript, so what if we just loop through all the Object tags within the Document Object Model, and replace the HTML? It could be done with one function call, and would not affect how you put the <object> and <embed> tags on the page.

The experiment that I tried does exactly that: it loops through all the <object> tags, and just replaces the HTML with exactly the same HTML. This makes IE think that the HTML is dynamically placed on the page, even though it started as just straight HTML.


The nice thing about this technique is that it could be easily retrofit onto older pages without touching the actual object/embed tags, and if JavaScript is disabled, it reverts to IE’s default behaviour but still at least shows the Flash content. It also will work with anything else that uses the <object> tag, such as with Java applets.

Unfortunately (well, fortunately, really), I don’t have the update installed yet and can’t test it myself. If anyone out there has it installed, could you let me know if you get the “click to activate content” flyover when mousing over the Flash movie in the patched version of IE 6? I have included a couple of sample Flash movies below that should trigger the new IE behaviour. The script is being called on this page, so for those with patched versions of IE 6, you should not get the mouse tooltip prompting you to click. If you try disabling JavaScript, you should get back the new IE behaviour.



If you want to try this for yourself, just place the code below in a file called replaceObjects.js .

// ------------------------------------
// Function replaceObjects
// Written by Nathan Derksen (http://www.nathanderksen.com/)
// A technique to get around the IE limitation placed due to the Eolas-Microsoft
// plug-in patent dispute.
//
// Usage:
// <head>...
//     <script type="text/javascript" src="replaceObjects.js"></script>
// </head>
// <body onload="replaceObjects()">
// ------------------------------------
function replaceObjects()
{
	var objectTagList;
	var newNode;

	if (document.replaceNode)
	{
		// Document.replaceNode does not work in Firefox, just in IE
		objectTagList = document.getElementsByTagName("object");
		for (var i=0; i < objectTagList.length; i++)
		{
			newNode = objectTagList[i].cloneNode(true);
			objectTagList[i].replaceNode(newNode);
		}
	}
}

— By Nathan Derksen     PermaLink

26 Responses to “A Potential Solution to the Eolas Flash Woes - The Object Replacement Method”

  1. tw Says:

    Sorry, doesn’t work here. Same behaviour, still
    IE 6.0.2900.2180_xpsp_sp2

  2. Nathan Derksen Says:

    Ok, thanks for checking. In the event that the issue is that it recognizes that the HTML being assigned, I just made a subtle change which modifies the HTML being assigned back in a very small way. Let me know if you still get the behaviour.

  3. ktec Says:

    Sorry, doesnt work here either. Still shows the “click to activate content” tooltip.
    Again, IE 6.0.2900.2180.xpsp_sp2

  4. Mike M Says:

    Sounded good, but it’s not working for me…

  5. steve Says:

    hey there - doesn’t work for me either (IE7b2 march 20 release) but i wanted to say i came across a similar technique to what you’re describing(http://therippa.blogspot.com/2006/03/activateactivex.html). in principle i really like the idea as it involves minimal work to fix old sites, but the downside of this approach seems to be that it’s tied to the onLoad event so it won’t execute until the *entire* page is rendered. if you have some flash on the long page (or one that’s loading slowly), the flash object could be available on the page for a few seconds before this javascript runs and fixes it. i don’t really think that’s acceptable, so personally i’m opting for the flashobject solution. it does require a bit of extra work, but i think it’s worth it.

  6. Nathan Derksen Says:

    Ok, well I will have to go to using DOM manipulation instead.

    Steve - yah, I thought of that too and thanks for the link. One possibility would be to have it run repeatedly until the page is complete using setInterval, but then I would also have to look for the closing object tag before replacing the whole thing lest you replace something which is currently only partially complete. Still, that might be a doable approach. It looks that I have some work ahead of me still to get this to work. So much for quick and simple :-)

  7. John Giotta Says:

    Just to toss this out there.
    I had to create a Flash Extension for the field producers for the company I work for.
    Its a FlashObject Template Extension.
    http://jdgiotta.googlepages.com/FlashObjectTemplate.mxp

  8. Nathan Derksen Says:

    John - Thanks, I’ll give that a look.

    All - I’ve updated the code to use DOM manipulation. Could I again get someone to let me know if it now removes the click to activate notice?

  9. Nathan Derksen Says:

    Oh, and FYI Adobe just released an updated publish template: http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=7c29e252

  10. joe Says:

    Sorry still same problem. Got the patch this morning and went freaking out accross the land.

    dirty microsoft faglots

  11. joe Says:

    supposidly this works… although it requires extensive retrofitting…

    http://blog.deconcept.com/flashobject/

  12. daniel Says:

    I really don’t see how anyone thinks the flashobject method above (http://blog.deconcept.com/flashobject/ ) is difficult. (It’s 1 line of code to include the .js file, and then one tiny block of javascript where you want the Flash to appear on-page. Compared to ANY other method I’ve seen and/or used, this is ridiculously easy…

  13. Nathan Derksen Says:

    No one is saying it is difficult, Flashobject is the nicest implementation of putting Flash on a page that I’ve come across. It’s just that if you can do a simple .js include across your site and it automatically makes everything work, it’s nicer than modifying each object instance on each page. It’s not a bit deal, this exercise is more about doing something “because I can”. :-)

  14. Steve Says:

    FlashObject is great. For existing pages (copius numbers of existing pages) — Here’s what I use. It is SIMPLE and it WORKS (for IE only)!

    For the record, I found this somewhere… Some comment on some blog, can’t remember where.

    This goes at the top of the page (it can go anywhere AFAIKT, but I put it near the top).

    and in your included js file:

    var objects=document.getElementsByTagName(’object’);
    for(var i=0;i

  15. Steve Says:

    Couldn’t get the top tag to go:) It was absorbed by the blog I guess. Here’s an image:

  16. Steve Says:

    Or no image I guess and the script got eaten:) Link here:
    http://www.dxstudio.com/forumtopic.aspx?topicid=69829e50-4e86-4c90-86cd-6a92bae7321e

    S

  17. Nathan Derksen Says:

    Cool, thanks! The wierd thing is that I tried that same technique, but had reports that it didn’t work. I’ll try it out again when I get a patched system that I can test with. I probably just missed something simple.

  18. flashape Says:

    hey, we just did something similar, and we found that the key is including the function that writes the flash content in an eternall text file…worked like a charm for us.

  19. flashape Says:

    ah sorry it looks like thats exactly what you’re doing already ;) i’m wondering if other people wrote the function on the page instaed of including it, and thats why it worked for you and not them?

  20. Nathan Derksen Says:

    Thanks, yah, still haven’t gotten the update yet. As soon as that happens I will resume work on getting this working. At the moment I can’t test it, but I know the other dude who got this working used an external script file as well. Wierd.

  21. Frode Rustoy Says:

    Fix for both Opera and MSIE!

    Put these two funtctions, included the call to addEvent at the bottom, in an EXTERNAL file and include the following line in any html-file. NB! Function MUST be in an external file!

    <script type=”text/javascript” src=”fix_eolas.js”&rt;</script&rt;

    // EXTERNAL file start: ———————————————
    // fix_eloas.js by Frode Rustoy.
    // By Frode Rustoy. http://www.vevemsteren.no/
    // Inspired by http://www.sitepoint.com/article/activex-activation-issue-ie
    function fix_eolas(){
    var objects = document.getElementsByTagName(”object”);
    for (var i = 0; i “)[0] + “>”;
    var newObject = tag + params + o.innerHTML + ” “;
    objects[i].outerHTML = newObject;
    }
    }

    addEvent(window, ‘load’,fix_eolas);

    // EXTERNAL file ends: ————————————————

  22. Frode Rustoy Says:

    OOPS! FOrgot to post the addEvent-function. Here it is complete:

    Fix for both Opera and MSIE!

    Put these two funtctions, included the call to addEvent at the bottom, in an EXTERNAL file and include the following line in any html-file. NB! Function MUST be in an external file!

    <script type=”text/javascript” src=”fix_eolas.js”&rt;</script&rt;

    // EXTERNAL file start: ———————————————
    // fix_eloas.js by Frode Rustoy.
    // By Frode Rustoy. http://www.vevemsteren.no/
    // Inspired by http://www.sitepoint.com/article/activex-activation-issue-ie
    function fix_eolas(){
    var objects = document.getElementsByTagName(”object”);
    for (var i = 0; i “)[0] + “>”;
    var newObject = tag + params + o.innerHTML + ” “;
    objects[i].outerHTML = newObject;
    }
    }

    function addEvent(obj, evType, fn){
    if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
    } else if (obj.attachEvent){
    var r = obj.attachEvent(”on”+evType, fn);
    return r;
    } else {
    return false;
    }
    }

    addEvent(window, ‘load’,fix_eolas);

    // EXTERNAL file ends: ————————————————

  23. Frode Rustoy Says:

    Fix for both Opera and MSIE!

    Put these two funtctions, included the call to addEvent at the bottom, in an EXTERNAL file and include the following line in any html-file. NB! Function MUST be in an external file!

    <script type=”text/javascript” src=”fix_eolas.js”></script>

    // EXTERNAL file start: —————————————————
    // fix_eloas.js by Frode Rustoy.
    // By Frode Rustoy. http://www.vevemsteren.no/
    // Inspired by http://www.sitepoint.com/article/activex-activation-issue-ie

    function fix_eolas(){
    var objects = document.getElementsByTagName(”object”);
    for (var i = 0; i < objects.length; i++) {
    var o = objects[i];
    var h = o.outerHTML;
    var params = “”;
    // Need to take care of each node because IE strips out Flashvars
    // if you just copy the object
    for (var j = 0; j<o.childNodes.length; j++) {
    var p = o.childNodes[j];
    if (p.tagName == “PARAM”){
    params += p.outerHTML;
    }
    }
    var tag = h.split(”>”)[0] + “>”;
    var newObject = tag + params + o.innerHTML + ” </object>”;
    objects[i].outerHTML = newObject;
    }
    }

    function addEvent(obj, evType, fn){
    if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
    }
    else if (obj.attachEvent){
    var r = obj.attachEvent(”on”+evType, fn);
    return r;
    }
    else {
    return false;
    }
    }

    addEvent(window, ‘load’,fix_eolas);

    // EXTERNAL file ends: —————————————————-

  24. Tobz Says:

    just a note that the above example uses invalid characters that need to be replaced: ” with ” else IE throws errors and js fails

  25. Tobz Says:

    well you get what i mean

  26. Nathan Derksen Says:

    Yah, I see them, thanks! Dang smart quotes :-)

Leave a Reply


Blog Categories

Browse by Date
April 2006
M T W T F S S
« Mar   Jul »
 12
3456789
10111213141516
17181920212223
24252627282930

Monthly Archives

Bloggers Area

XML Feeds Option