Javascript Flash Detect Script

Place this code in a .js file and link it in the head of your document:

function FlashInstalled()
{
result = false;
if (navigator.mimeTypes && navigator.mimeTypes[”application/x-shockwave-flash”])
{
result = navigator.mimeTypes[”application/x-shockwave-flash”].enabledPlugin;
}
else if (document.all && (navigator.appVersion.indexOf(”Mac”)==-1))
{
eval (’try {var xObj = new ActiveXObject(”ShockwaveFlash.ShockwaveFlash”);if (xObj) result = true; xObj = null; } catch (e) {}’);
}
return result;
}
function FlashWrite(url,width,height)
{
document.write(’<OBJECT classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″‘);
document.write(’ codebase=”http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0″ ‘);
document.write(’ WIDTH=’ + width + ‘ HEIGHT=’ + height + ‘>’);
document.write(’ <PARAM NAME=movie VALUE=”‘ + url + ‘”> <PARAM NAME=loop VALUE=false> <PARAM NAME=quality VALUE=best> <PARAM NAME=scale value=exactfit> <PARAM NAME=bgcolor VALUE=#CCFFFF> <PARAM NAME=menu value=false> ‘);
document.write(’ <EMBED xsrc=”‘ + url + ‘” quality=best bgcolor=#CCFFFF loop=false scale=exactfit menu=false ‘);
document.write(’ swLiveConnect=FALSE WIDTH=’ + width + ‘ HEIGHT=’ + height);
document.write(’ TYPE=”application/x-shockwave-flash” PLUGINSPAGE=”http://www.macromedia.com/shockwave/download/index.cgi?
P1_Prod_Version=ShockwaveFlash”>’);
document.write(’ </EMBED></OBJECT>’);
}

You can call the above code flash.js file and link it in the head of your document like this:

<script language="JavaScript1.2" xsrc="flash.js" mce_src="flash.js" type="text/javascript"></script>

Then where you want your flash file to appear, place this code:

<script Language = "JavaScript" type="text/javascript">
if (FlashInstalled())
{
FlashWrite(’images/flash/yourflashfile.swf’,468,240);
}
else
{
var url = “linkyourflatimagetosomefile.php”
var image = “<img alt=’Name of your flat image’ xsrc=’images/flash/yourstillimage.jpg’ height=240 width=468 border=0>”
document.write(image.link(url));}</script>
<noscript><a xhref=’linkyourflatimagetosomefile.php’><img alt=’Name of your flat image’ xsrc=’images/flash/yourstillimage.jpg’ height=240 width=468 border=0></a>
</noscript>

If the browser doesn’t have flash installed or doesn’t have java turned on, they will see yourstillimage.jpg instead of the flash file. Change the file width and height to match your .swf and image files.

Comments are closed.

"No one can act alone in the name of all, and no one can accept the anarchy of a society without rules. Multilateralism is the key, for it ensures the participation of all in the management of world affairs. It is a guarantee of legitimacy and democracy in matters regarding the use of force."

- Jacques Chirac
Go to the Top of the Page
Search this Site
Sibagraphics
ABN40098165406 / QLD BN17649330
P.O. Box 259, Pomona, Qld Australia 4568
Ph: +61 (0)7 5485 2085
Mob: +61 (0)412 665 189

Visitor locations

Valid XHTML 1.0 / Valid CSS Copyright | Privacy | Disclaimer
Copyright © 1998 - 2008 Sibagraphics
Page last modified October 11, 2007.