Skip to content

Instantly share code, notes, and snippets.

@melchoy
Created January 2, 2010 03:15
Show Gist options
  • Save melchoy/267364 to your computer and use it in GitHub Desktop.
Save melchoy/267364 to your computer and use it in GitHub Desktop.
Flash Player Detection
/**********************************************
* Flash Player Detection (taken from sifr )
**********************************************/
var hasFlash = function(){
var nRequiredVersion = 9;
if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") > -1){
document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & ' + nRequiredVersion + '))) \n</script\> \n');
/* If executed, the VBScript above checks for Flash and sets the hasFlash variable.
If VBScript is not supported it's value will still be undefined, so we'll run it though another test
This will make sure even Opera identified as IE will be tested */
if(window.hasFlash != null){
return window.hasFlash;
};
};
if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
var flashDescription = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description;
return parseInt(flashDescription.substr(flashDescription.indexOf(".") - 2, 2), 10) >= nRequiredVersion;
};
return false;
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment