View Full Version : Replacing a flash file with a gif if no flash is detected

Apr 13th, 2005, 12:07 PM
I have found a bit of javascript that detects whether the user has flash or not and what version, but when I try to replace the flash file with a gif if they haven't got it nothing works.

I've tried within the if statement:


to change the source of the file to the gif.

How do I target the flash file in my body tag, I've given it a name bannerFlash but it doesn't recognise it.

Please can somebody help

Apr 13th, 2005, 12:21 PM
This is just a long shot, but how about using document.write to create the necessary html based on the if statement?

if (user has flash) {
document.write("<embed src=....");
else {
document.write("<img src=.....");
}Put this script in the body tag where the flash file or the image is supposed to come.

Apr 13th, 2005, 03:23 PM
Here's another method. I haven't used it myself but it might do what you need.


If you were to look at the source code of the home page at Macromedia.com, youíd see that they serve up an alternative image if the user canít view Flash movies. They are detecting the Flash Player with JavaScript, and then using JavaScript to dynamically write out HTML based on the detection. Ugly, ugly, ugly. Hereís how Iíd do it:

<object type="application/x-shockwave-flash
width="400" height="300">
<param name="movie"
value="c.swf?path=movie.swf" />
<img src="noflash.gif"
width="200" height="100" alt="" />

If the browser doesnít know how to play objects with a MIME type of application/x-shockwave-flash, it will simply go for the next child element and give that a try. Iím guessing that a simple image element should be okay for most people. Failing that, you can simply use text.