Skip to content

Instantly share code, notes, and snippets.

@dciccale
Created August 31, 2011 09:37
Show Gist options
  • Save dciccale/1183176 to your computer and use it in GitHub Desktop.
Save dciccale/1183176 to your computer and use it in GitHub Desktop.
Detect if Flash Player is installed in your browser and get its version (180bytes)
function(a, b) {
try {
b = new ActiveXObject(a+b+'.'+a+b).GetVariable('$version')
} catch (e) {
b = navigator.plugins[a+' '+b];
b = b ? b.description : "";
}
return b.match(/\d+/)[0];
}('Shockwave','Flash')
function(a,b){try {b=new ActiveXObject(a+b+'.'+a+b).GetVariable('$version')}catch(e){b=navigator.plugins[a+' '+b];b=b?b.description:''}return b.match(/\d+/)[0]}('Shockwave','Flash')
<!doctype html>
<head>
<title>Detect Flash Player</title>
<script>
var flashPlayer = function(a,b){try {b=new ActiveXObject(a+b+'.'+a+b).GetVariable('$version')}catch(e){b=navigator.plugins[a+' '+b];b=b?b.description:''}return b.match(/\d+/)[0]}('Shockwave','Flash');
if(flashPlayer) {
alert("Flash Player " + flashPlayer + " is installed");
}
else {
alert("Your browser doesn't have Flash Player installed");
}
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment