|
|
|
Latest Entries 25/06 Dr. Madness on IE7 06/09 Dr. Madness on Web 2.0 15/08 Dr. Madness on Flash/Eolas 13/07 Dr. Madness on books 12/07 Dr. Madness on DRM 12/07 The doctor is in! View all Need to spew? Want to share some of your own madness? DrMadness@DrMadness.com If you're looking for the old DRM Madness site, please click here. |
Dr. Madness on Flash/Eolas
So, I was making a website for work. The designer had made fairly heavy use of flash and so, thanks to Eolas, users of the latest Inernet Explorer and Opera browsers have to click on the flash before it works, and IE shows a 'nice' border too. Ofcourse, I could not allow such unholy things to take place just because some researcher suddenly got greedy. So I started browsing the net for fixes, but I didn't really find any nice ones. So I decided to take 5 minutes and write a clean, simple, short one myself. Looking around, I found several awkward ways of getting around the problem. Adobe (they bought Macromedia, so now Flash is from Adobe), for example, made a nice 10kb JavaScript that does indeed seem to work, but is fairly heavy for what we are trying to do. I found several other solutions that worked more or less in the same way, creating a Flash object in JavaScript, assigning the parameters, etc. I sneeze at those solutions. Several other folks came up with using document.write in an external JavaScript which is also not a nice solution, since you're not allowed to use that in XHTML. Ok, XHTML is hardly implemented yet (it's hard when Internet Explorer doesn't fully support it), but still, I try to be ready for XHTML so it is not an option. Some people went as far as putting the entire code to get the Flash working in the external JavaScripts, so instead of defining what Flash will be seen in the HTML page, you need to write a different JavaScript for each.
For both kinds of solutions mentioned above I found scripts that would simply not work when you had more than one flash on the page. Obviously that adds to not wanting to use those solutions. Anyway, reading through some of these things, it became pretty obvious that the whole deal was simply to not have the code to embed the Flash in your HTML, but in an external JavaScript. So here's my simple solution. Most site developers use at least one external JavaScript file for every site that every page on that site uses. Let's add a simple function to that (or create a whole new JavaScript file, if you want): function doFlash(id, content) { document.getElementById(id) = content; } Now, in your original HTML, you will have something like <object id="......</object>. First, make sure that the attributes of the tags all use double quotes " instead of single quotes '. Then, change it into this:
<script type="text/javascript" src="some-script.js"></script> Indeed, copy the entire object tags and everything in between onto one line and use it as parameter. I'll assume I wont have to tell you to change some-script.js to the script you are really using, or ommit it if you have put the function in a script already loaded on every page. Ofcourse you can put multiple of these blocks in your HTML, but make sure to adjust the id's, and include the script (first line) only once. So why do I like this solution more than others? Firstly, because the JavaScript function created is essentially a one-liner and can be easily dumped into an external JavaScript you already use. Secondly, because it does muck about with creating objects in JavaScript and the timeconsuming way to assign parameters correctly. Thirdly, it's mostly copy/pase with a few times pressing delete and/or backspace from the HTML output generated by the Flash development environment. Last but not least, it's not 10kb for a 3 liner fix, like some 'official' solutions out there. If you've done it once or twice, you can implement this fix, workaround, patch, whatever you want to call it, in less than 15 seconds per Flash - hooah! Note that this fix has been tested with the latest Internet Explorer and Opera, and works great for both.
First created on 15-08-2006 at 21:01:31, last modified on 15-08-2006 at 23:30:55.
Comments
|
|
Copyright (C) 2006 DrMadness.com |
|