How to Fix Web Pages with Active Content | WebReference

How to Fix Web Pages with Active Content

How to Fix Web Pages with Active Content

By Ronald Northrip.

Microsoft got sued, but there's nothing new in that. The problem is that they lost to Eolas, and as part of the results of that lawsuit they've changed the way that Internet Explorer deals with active content. Up until now this change was only shown in beta versions of the browser, but a recent security patch to IE for XP SP2 has put this out in the real world, and what was once theoretical has now become a part of your Web site's audience.

Flash Animations, QuickTime Movies and Java Applets seamlessly integrated into the content on a Web page or Web site has been the trademark of the best Web developers. But this change in Internet Explorer breaks that seamlessness by disabling active content and even going so far as to prompt the user before displaying active content elements (placed using object, embed, applet tags). Your audience will see things like this:

This is a pain, but it’s not the first time this has happened. Remember having to replace your EMBED tags with the combination OBJECT/EMBED tags that we use regularly today? It was a lot of work then, and it's going to be a lot of work now. What makes this even worse is that the solution is not just an extra tag (like last time), this problem can only be solved by using JavaScript.

So how do I fix it?

Download the example files from my website so you can follow along.

The sad thing is that you can't fix it directly. Any placement of active content by HTML tags will have this problem. The trick is to work around the problem by letting JavaScript do the job. According to Microsoft, if you don’t put the code within the page or directly generate it while the page is loading it won’t trigger the prompts. The solution is to extract the code to an external JavaScript file and call that code as a function.

For example, open the "anim.html" file that you downloaded, and find an object tag like this:

Copy that code.

Create a new blank text file and save it as "ObjectScript.js". In this file create a JavaScript function that will create the object code for us.

Please note, in the document.write command there are two single quotes. That's because the code you copied from the original HTML document probably has lots of double quotes in it and we don't want to create problems later. Single quotes on the outside will not conflict with double quotes on the inside. Now within the single quotes paste the code you copied from the HTML document so it looks like this:

If you want, you can break it up over multiple document.write commands to make it easier to read.

Go back to the original HTML file and replace the original set of tags (<object ...><param ...><embed ...></object>) with a link to the external JavaScript file and a call to the function you created. It should look like this:

You have to do this for every object, embed or applet tag -- and multiple times on a single Web page if you have multiple active elements.


Created: March 27, 2003
Revised: May 19, 2006