Every now and then I have found myself on the hunt for some “simple” yet robust flash detection. This can be pretty easy to rip off from other sites but there seems to be quite afew different ways to deal with this and ofcourse the whole cross compatibility issues involved. I also really wanted one which didnt use the VBscript tags to try and create objects so after spending time on the hunt and finding nothign that really fitted what i wanted, i thought I’ll hack together a function which would. It incroperates quite a few bits from other sources but really just manguling together bits and tiding them up to fit my purpose.
The end result is a small and clean function that should work in both IE, firefox / mozilla browsers.
Javascript function is below:
function HasFlash(MM_contentVersion){
var MM_FlashCanPlay = false;
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];
}
MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
} else if (navigator.userAgent && navigator.userAgent.indexOf(“MSIE”)>=0&& (navigator.appVersion.indexOf(“Win”) != -1)) {
try {
var flash = new ActiveXObject(“ShockwaveFlash.ShockwaveFlash.”+MM_contentVersion);
MM_FlashCanPlay = true;
}
catch (err){
MM_FlashCanPlay = false;
}
}
return MM_FlashCanPlay;
}