If you want to use Flash on your website, but you also want to provide an alternative for those users who don't have Flash installed, then you can use this bit of unobtrusive JavaScript.
Below you should be able to see either the Flash object, or its alternative.
This is the Flash alternative.
First you need to create your webpage with the Flash alternative wrapped in a simple <div>. This needs to have a unique ID so its contents can be replaced later...
<div id="flashExample"> <p>This is the Flash alternative.</p></div>
Next, you need to download my script.js and flashReplace.js files, then create an additional configuration file like flashExample.js (explained later) and include them all in the pages <head>, like so:
<script type="text/javascript" src="scripts.js"></script><script type="text/javascript" src="flashReplace.js"></script><script type="text/javascript" src="flashExample.js"></script>
Then in your configuration file (flashExample.js), you need to change the general setup:
Still in the configuration file, the addFlashObject line needs to be updated... it is possible to copy this line multiple times, but for each one, the order of the parameters is:
If you want to have links to enable or disable the Flash on your website, create an element with an id of 'flashDisableLinks', like so:
<p id="flashDisableLinks"></p>
You don't really need the full scripts.js file, as we only use the addLoadEvent function. But it does contain other functions which are handy to have lying around.
The background colour is typically specified as 'transparent', but it is perfectly valid to use a hexadecimal colour like '#F00'.
The elements which make up the Flash alternative are not actually deleted from the DOM, instead its off-screened with CSS, so it is possible to use it in the print style sheet.
If use the flash detection object (which has issues in Flash 10), you can also download its source code.
Any feedback would be greatly appreciated. If you would like to use this code, please read the licence it is released under.