Skip to content

Instantly share code, notes, and snippets.

@mjuhl
Created September 7, 2012 16:33
Show Gist options
  • Save mjuhl/3667611 to your computer and use it in GitHub Desktop.
Save mjuhl/3667611 to your computer and use it in GitHub Desktop.
A function for detecting flash version
function getFlashVersion (majorVersion /* = true */) {
if (majorVersion !== false) {
var majorVersion = true;
}
// detect flash version
var flashVersion = '0,0,0';
// ie
try {
try {
// avoid fp6 minor version lookup issues
// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
try {
axo.AllowScriptAccess = 'always';
}
catch(e) {
flashVersion = '6,0,0';
}
} catch(e) {
// no flash
}
flashVersion = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g , ',').match(/^,?(.+),?$/)[1];
// other browsers
} catch(e) {
try {
if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
flashVersion = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
}
} catch(e) {
}
}
if (majorVersion) {
return flashVersion.split(',').shift();
} else {
return flashVersion;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment