If your web site users are using IPad or IPhone or simply if they disabled flash on their browser you need to replace the ugly icon with a beautiful image.
Here is the magic script, copied from the web site http://www.kirupa.com/developer/mx/detection.htm, the script shows the swf flash or replaces it with an image if Flash is not supported.
<SCRIPT LANGUAGE=JavaScript1.1>
<!--
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words[i])))
continue;
var MM_PluginVersion = words[i];
}
var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next \n');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
document.write(' ID="script" WIDTH="300" HEIGHT="200" ALIGN="">');
document.write(' <PARAM NAME=movie VALUE="script.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> ');
document.write(' <EMBED src="script.swf" quality=high bgcolor=#FFFFFF ');
document.write(' swLiveConnect=FALSE WIDTH="300" HEIGHT="200" NAME="script" ALIGN=""');
document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
document.write(' </EMBED>');
document.write(' </OBJECT>');
} else{
document.write('<IMG SRC="script.gif" WIDTH="300" HEIGHT="200" usemap="#script" BORDER=0>');
}
//-->
</SCRIPT><NOSCRIPT><IMG SRC="script.gif" WIDTH="300" HEIGHT="200" usemap="#script" BORDER=0></NOSCRIPT>
Replace the script.swf file name with your flash and replace the script.gif image with your replacement image name.
This script is tested and working!
Many thanks for sharing this, was really helpful!
ReplyDeleteIf you go to use this just be sure to spot, and change the image dimensions to whatever you need.
Hi
ReplyDeleteWhere do you place this script?
Hi,
ReplyDeletethanks for the script! Is it possible to add a link to the image? If yes how should I define this? Can I just add link tags around the im tag?
Hello,
ReplyDeletelook at the latest document.write...
just surround the IMG tag with an href tag... that's all.
Where do I place this script? In the Head? After or before the Flash Code?
ReplyDeleteThis works great... except... the flash now stays on top of all layers. Even with z-index set at 1 and an image inside a div at z-index set at 2, the flash still shows on top.
ReplyDeleteanyway to fix this?
thanks
Hi Mo, thanks for using my blog!
ReplyDeleteThe flash zindex problem is known by the community, try these links, they will guide you to the solution:
http://kb2.adobe.com/cps/155/tn_15523.html and
http://forums.precharge.com/website-design/420-z-index-stack-order-problem.html
You need to work on flash properties.
Hope it helps!
I used this script with a redirection to a non flash device friendly website as an else command at the end instead of an image.
ReplyDeleteHere's the final code:
else{
window.location.replace("http://www.script.domain extension");
}
Just replace the website domain and you're there.
Thanks for the initial excellent code, a big help!
Thank you for your code, I appreciate it!
ReplyDeleteFor me, this code works for FireFox, Chrome, and Opera. When viewing in Safari on iPhone and iPad, it also works (displays image).
ReplyDeleteInternet Explorer however, displays the alternate image, even though flash is installed, and displays the swf normally without this code.
Thoughts?
Never mind! Found the problem. Internet Explorer was reporting latest Flash module... but wasn't loading the addin.
ReplyDeleteThank you IE, you consistently make my life happier.
Thank for this post! Very helpful!
ReplyDeleteMany thanks, this has cleared up a issue for one of our clients who wants to use a flash logo but appear on iPhone/iPads
ReplyDeleteYou are welcome, I'm happy to be useful!
ReplyDeleteWhere Do you put this Script? and mine is a slide show in flash will this still work ?
ReplyDeleteHi There Where exactly do I put this code into my php file I assume ? and I have got a carousal slide show on my front page in flash, will this still work for me ? As looks bad with no image on iphone ipads etc
ReplyDeletePut the script in the HEAD section of your php file, it will be executed on the client side.
ReplyDeleteWhy don't you use a Javascript carousel? It's compatible with Iphone/Ipad and there are a lot out of there.