Excuse me sir, your Flash is broken!

by Joe Gillespie — Nov 1, 2003

Microsoft have just been successfully sued for half a billion dollars by a small company called Eolas, who claim to hold the patent rights for the technology that permits plug-ins like Flash and QuickTime to work in browsers – and the judges seem to agree. The upshot of all this is that Microsoft has to alter Internet Explorer so that plug-ins can't launch automatically as they do at present. This is true for all Active-X and Java applets as well. A modified version of IE, due early next year, will simply put up a dialog box asking if you want to view the content – with just an 'OK' button, so you don't really have much choice.

press ok

Is that stupid or what?

If you have Flash, content on your page, or anything else that depends on plugins, in the next few months, your IE-using audience are going to be hassled by this inane step. It remains to be seen how or if other browsers will be affected.

One way to circumvent this nonsense is to use JavaScript to 'document.write' your Flash content, then the 'OK' button won't appear and everything will be back to 'normal'. Unfortunately, this means a little extra work for you!

Normally, you would insert something like this into your HTML to display a Flash movie...

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/
    swflash.cab#version=6,0,29,0" width="468" height="60">
        <param name="movie" value="../flash/nano.swf">
        <param name="quality" value="high">
        <embed src="../flash/nano.swf" quality="high"
            pluginspage="http://www.macromedia.com/go/getflashplayer"
            type="application/x-shockwave-flash" width="468" height="60">
        </embed>
</object>

To do this with JavaScript requires that you document.write() the code from an external JavaScript file – it won't work if you embed the JavaScript within your HTML page.

First, insert the reference to the external JavaScript file in the head of the page:-

<script src="flashHelper.js" type="text/javascript" language="javascript">

Put this script on your page where you want the Flash to play:-

<script type="text/javascript" language="javascript">
    <!--
        playFlash("
flash/mymovie.swf",120,80);
    //-->
</script>

Substitute your own movie's file path, width and height for the green text. The external script, which I've called 'flashHelper.js', goes like this:-

function playFlash(f,w,h)
    {
    document.write('<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-
        444553540000 codebase="http://download.macromedia.com/pub/
        shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width=
'+w+'
        height=
'+h+'><param name="movie" value='+f+'>
        <param name="quality" value=high><embed src="
'+f+'"
        quality=high pluginspage="http://www. macromedia.com/
        shockwave/download/index.cgi?P1_Prod_Version=
        ShockwaveFlash" type="application/x-shockwave-flash"
        width=
'+w+' height='+h+'></embed></object>');
      }

As the object code already has a load of double quotes in it, I can wrap it all in a set of single quotes – that's easier than changing all the double quotes to single ones inside double quotes. I then have to get rid of the line breaks and close everything up into one long line.

So, there you have Flash that won't throw up any stupid dialogs. As a side benefit, it will also allow your page to validate because any page with an <embed> tag won't. The other workarounds suggest by Microsoft won't validate either. Wrapping it in an external script like this hides it from HTML validation.

Del.icio.us Digg Technorati Blinklist Furl reddit Design Float