almorris
asked on
No flash then display jpeg
I have a flash logo on my website. If a visitor does not have the flash 6 plugin it asks them to download it. Is there a way for me to detect if the user has the plugin and if not then just display a JPEG logo instead?
Thanks
Aaron
<object classid="clsid:D27CDB6E-AE 6D-11cf-96 B8-4445535 40000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="400" align="middle">
<param name="movie" value="logo2.swf">
<param name="quality" value="high">
<PARAM NAME="LOOP" VALUE="false">
<embed src="logo2.swf" width="600" height="400" align="middle" quality="high" loop=false pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockw ave-flash" ></embed>
Thanks
Aaron
<object classid="clsid:D27CDB6E-AE
<param name="movie" value="logo2.swf">
<param name="quality" value="high">
<PARAM NAME="LOOP" VALUE="false">
<embed src="logo2.swf" width="600" height="400" align="middle" quality="high" loop=false pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockw
This is possible with JavaScript:
<script>
<!--
function hasflash(){
for (i=0;i<navigator.plugins.l ength;i++) {
if (navigator.plugins[i].name .indexOf(" Flash")>=0 ){
return true;
}
return false;
}
// -->
</script>
Then, inside your body, you only need a script that calls the hasflash() function like this:
<body>
<script>
<!--
if (hasflash()) {
document.write(CODE FOR FLASH);
}
else{
document.write(CODE FOR JPEG);
}
// -->
</script>
It may be better if you even used this with PHP to have the document.write substituted by echo(), but both should work.
--Zyloch
<script>
<!--
function hasflash(){
for (i=0;i<navigator.plugins.l
if (navigator.plugins[i].name
return true;
}
return false;
}
// -->
</script>
Then, inside your body, you only need a script that calls the hasflash() function like this:
<body>
<script>
<!--
if (hasflash()) {
document.write(CODE FOR FLASH);
}
else{
document.write(CODE FOR JPEG);
}
// -->
</script>
It may be better if you even used this with PHP to have the document.write substituted by echo(), but both should work.
--Zyloch
Zyloch's comment will only work in Netscape / Mozilla and Opera because Internet Explorer does not give you the navigator.plugins list.
I suggest that you use no scripting but let browsers without the plugin fall back on using the HTML code "inside" the OBECT tag.
First, remove the codebase reference to prevent the browser from asking the user if it should download it. I have also added a TYPE parameter to your OBJECT tag for browsers that do not understand a classid (this is used only by IE AFAIK).
<object classid="clsid:D27CDB6E-AE 6D-11cf-96 B8-4445535 40000" width="600" height="400" align="middle" type="application/x-shockw ave-flash" >
<param name="movie" value="logo2.swf">
<param name="quality" value="high">
<PARAM NAME="LOOP" VALUE="false">
<embed src="logo2.swf" width="600" height="400" align="middle" quality="high" loop=false type="application/x-shockw ave-flash" >
<img src="mylogo.jpg" width="600" height="400" alt="My company logo" />
</embed>
</object>
For old Netscapes you may have to add <noembed> tags around the image.
The above code should be handled by the browser as follows:
1) Voila, here is an OBJECT. If I understand this tag and can handle this file type with one of my plugins, I'll invoke the plugin and display it. if not...
2) Well, here is an EMBED tag. If I understand this tag and can handle this file type with one of my plugins, I'll invoke the plugin and display it. if not...
3) A good old IMG tag - since I for one reason or another couldn't make sense of the two other tags I'll just retrieve and display this image.
Gotcha: This is correct behaviour according to the HTML specification. Actual implementation in browsers may vary, as always...
I suggest that you use no scripting but let browsers without the plugin fall back on using the HTML code "inside" the OBECT tag.
First, remove the codebase reference to prevent the browser from asking the user if it should download it. I have also added a TYPE parameter to your OBJECT tag for browsers that do not understand a classid (this is used only by IE AFAIK).
<object classid="clsid:D27CDB6E-AE
<param name="movie" value="logo2.swf">
<param name="quality" value="high">
<PARAM NAME="LOOP" VALUE="false">
<embed src="logo2.swf" width="600" height="400" align="middle" quality="high" loop=false type="application/x-shockw
<img src="mylogo.jpg" width="600" height="400" alt="My company logo" />
</embed>
</object>
For old Netscapes you may have to add <noembed> tags around the image.
The above code should be handled by the browser as follows:
1) Voila, here is an OBJECT. If I understand this tag and can handle this file type with one of my plugins, I'll invoke the plugin and display it. if not...
2) Well, here is an EMBED tag. If I understand this tag and can handle this file type with one of my plugins, I'll invoke the plugin and display it. if not...
3) A good old IMG tag - since I for one reason or another couldn't make sense of the two other tags I'll just retrieve and display this image.
Gotcha: This is correct behaviour according to the HTML specification. Actual implementation in browsers may vary, as always...
ASKER
hallvord your comment looks the way to go as I do want this action in IE. One thing I found is that when I tested it on win98 that had IE5 it thought my plugin was flash 3 (I guess this is what shipped with 98) and would not run the animation. Is there away for me to see if it's version 6 like I have. I guess the application/x-shockwave-fl ash id's all versions of flash.
Thanks
Aaron
Thanks
Aaron
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See the article for more, but it basically means you can perform an
if(strpos($_SERVER['HTTP_A
to find out. This still leaves you with the fact that you won't find out if people have an older version of Flash, but thats dealt with more on the link above.