Richard Szalay

Thursday, April 20, 2006

Internet Explorer: IE ActiveX Update Workaround

Many of you will now be familiar with the update made to internet explorer, whereby you need to 'click to activate' any activex controls on a page.

To get around this, I have created a script that you can include in your page (via an external JS file) that basically rewrites all object tags on the page. As the creation of object elements has been done by an external file, IE will allow interaction without activation.

All you need to do is add the script reference just before the end of your body tag.

// test.html
<html>
<body>

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="740" height="195" id="main_flash">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="movie" value="main_flash.swf" />
    <param name="wmode" value="transparent">
    <param name="quality" value="high" />
    <param name="bgcolor" value="#000000" />

    <embed src="main_flash.swf" quality="high" width="740" height="195" name="main_flash" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

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

</html>
// ieactivexfix.js
if (document.all && document.getElementsByTagName) for (var i=0, els=document.getElementsByTagName("object"); i<els.length; els[i].outerHTML = els[i++].outerHTML);