Hello all, I’ve been using the Kirupa tuts for while but Ive got one that I need some help to adapt. I want to adapt the Kirupa flash detection script from this page: http://www.kirupa.com/developer/mx/detection.htm (near the bottom) whereby if the flash plugin is installed the flash element is shown, if not an image is used instead
*What I want to do is say - If the flash plugin is installed change the CSS background-color of an elements ID, if not installed change the CSS background-color of different elements ID.
-I figure it has something to do with the JavaScript ‘getElementbyID’ but being a bit of a Javascript muppet Ive only had limited success…
-I know for example that Javascript refers to the CSS properties slightly differently: http://codepunk.hardwar.org.uk/css2js.htm
This is what I have written BUT it works only in Firefox, not IE… how should I write this properly?
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<title>Flash Detection changing the CSS Style</title>
<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1” />
<SCRIPT LANGUAGE=JavaScript1.1>
<!–
function test() {
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*)))
continue;
var MM_PluginVersion = words*;
}
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>
'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next
');
document.write(‘MM_FlashCanPlay = ( IsObject(CreateObject(“ShockwaveFlash.ShockwaveFlash.” & MM_contentVersion)))
‘);
document.write(’</SCR’ + 'IPT>
');
}
if ( MM_FlashCanPlay ) {
document.getElementById(“hasflash”).style.backgroundColor=“yellow”;
} else{
document.getElementById(“noflash”).style.backgroundColor=“yellow”;
}
}
//–>
</SCRIPT>
<style>
#hasflash {
font-size:26px;
font-family:Arial, Helvetica, sans-serif;
}
#noflash {
font-size:26px;
font-family:Arial, Helvetica, sans-serif;
}
</style>
</head>
<body onload=“test()”>
<div id=“hasflash”>Has flash</div>
<div id=“noflash”>No flash</div>
</body>
</html>
Cheers, Richter