For all of you that are too lazy to read all the following introduction, jump right ahead to EOLATOR my automatical HTML page transformer that does all the ugly activeX to javascript work that lies ahead for you.
By now we all should have heard it - as Microsoft wants to save themselves some 521 million dollars they will soon make some updates to their Internet Explorer that allow them to sneak out of one of these absolutely bogus trivial patent cases. Unfortunately this little update will cause an alert box to pop up whenever an active-x plugin inside an HTML page is started. This is something that affects us flash developers painfully. Fortunately Macromedia has already published some possible cures that you will have to apply to all sites that you've ever built that use flash.
I had a look at the scripts that Macromedia provides - looks like solid work, nicely documented, the compatibility charts suggest that there has been lots of testing. But: why is this code so huge? Why is the way that the data is written so complicated and error prone? It looks like you will have to go by hand through your <OBJECT> tags, pick out the correct name/value pairs and paste them one by one into some javascript function. This is a process where in 1 out of 10 cases you will either loose some letters, mix up the order or forget some tags. And it's too much work if you have to update some dozens of pages. Unnecessary work I think.
That's why I made some tests with the IE beta that Microsoft offers and came to the following result: the only thing that really has to come from an external Javascript file is the "document.write()" command that dynamically places the <OBJECT> tag into the page. You can leave all the real data inside the HTML page. That includes the <OBJECT> data itself - in form of javascript of course.
What I don't like about Macromedia's solution is that I have to wade through old <OBJECT> tags which consist out of even more <PARAM> tags and sort them all out. What I prefer is to simply cut out the whole block and paste it into some javascript expression. But stop! Don't forget that we are possibly dealing with various quotation marks like " or ' or even linebreaks which forces us to wrap up that textblock in a way that it cannot break our javascript routine. Here comes PHP in very handy - I use its "urlencode" command to create a format that can be mindlessly put between quotation marks. And javascript offers a neat counterpart in the form of "unescape". And that's it. The final result looks like this:
<script language="JavaScript" type="text/javascript" src="quasimondo_vs_eolas.js"></script>
<script language="JavaScript" type="text/javascript">
insertObject(unescape("%3COBJECT classid%3D%22clsid%3AD27CDB6E-AE6D-11cf-96B8-444553540000%22%0A codebase%3D%22http%3A%2F%2Fdownload.macromedia.com%2Fpub%2Fshockwave%2Fcabs%2Fflash%2Fswflash.cab%23version%3D6%2C0%2C79%2C0%22%0A WIDTH%3D%22600%22 HEIGHT%3D%22130%22 id%3D%22eolator_head%22 ALIGN%3D%22%22%3E%0A %3CPARAM NAME%3Dmovie VALUE%3D%22eolator_head.swf%22%3E %3CPARAM NAME%3Dquality VALUE%3Dhigh%3E %3CPARAM NAME%3Dbgcolor VALUE%3D%23CCCC99%3E %3CEMBED src%3D%22eolator_head.swf%22 quality%3Dhigh bgcolor%3D%23CCCC99 WIDTH%3D%22600%22 HEIGHT%3D%22130%22 NAME%3D%22eolator_head%22 ALIGN%3D%22%22%0A TYPE%3D%22application%2Fx-shockwave-flash%22 PLUGINSPAGE%3D%22http%3A%2F%2Fwww.macromedia.com%2Fgo%2Fgetflashplayer%22%3E%3C%2FEMBED%3E%0A%3C%2FOBJECT%3E"))
</script>
Okay - this doesn't look as nice as Macromedias version, but it also doesn't need a 7K and a 5K external library - my quasimondo_vs_eolas.js is just 53 byte.
I have turned this into a little widget called EOLATOR which you are free to use - AT YOUR OWN RISK of course. The pages that I have converted until now work fine, but all this is so fresh that we don't know if Microsoft even get's through with their little trick. Should you come across any errors - the comments are yours:
Posted at October 07, 2003 10:23 PM | Further reading
