Created
July 6, 2015 13:46
-
-
Save funkjedi/8c3c62d5255146225d3e to your computer and use it in GitHub Desktop.
Get Flash Version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Based on goog.userAgent.flash | |
* @license Apache-2.0 | |
* @see {@link https://code.google.com/p/closure-library/source/browse/closure/goog/useragent/flash.js} | |
*/ | |
function getFlashVersion() { | |
var getVersion = function(desc) { | |
var matches = desc.match(/[\d]+/g); | |
if (!matches) { | |
return ""; | |
} | |
matches.length = 3; | |
return matches.join('.'); | |
}; | |
if (navigator.plugins && navigator.plugins.length) { | |
if (navigator.plugins['Shockwave Flash 2.0']) { | |
return '2.0.0.11'; | |
} | |
var plugin = navigator.plugins['Shockwave Flash']; | |
if (plugin) { | |
if (plugin.description) { | |
return getVersion(plugin.description); | |
} | |
} | |
} | |
else { | |
if (navigator.mimeTypes && navigator.mimeTypes.length) { | |
var mimeType = navigator.mimeTypes['application/x-shockwave-flash']; | |
if (mimeType && mimeType.enabledPlugin) { | |
return getVersion(mimeType.enabledPlugin.description); | |
} | |
} | |
else { | |
try { | |
var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7'); | |
return getVersion(ax.GetVariable('$version')); | |
} | |
catch (e) { | |
try { | |
var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); | |
return '6.0.21'; | |
} | |
catch (e) { | |
try { | |
var ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); | |
return getVersion(ax.GetVariable("$version")); | |
} | |
catch (e) {} | |
} | |
} | |
} | |
} | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment