Skip to content

Instantly share code, notes, and snippets.

@funkjedi
Created July 6, 2015 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funkjedi/8c3c62d5255146225d3e to your computer and use it in GitHub Desktop.
Save funkjedi/8c3c62d5255146225d3e to your computer and use it in GitHub Desktop.
Get Flash Version
/**
* 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