Get supported flash version

2010-06-07

This is a simple Javascript function to detect the supported version of flash. It's not quite fool proof. I've created it a while ago (using other examples) and don't even know whether and how good it'll work. But if it b0rks you might use it as a point of reference :) Anyways, good luck with it. Don't use that swfobject script. It's running under the bloatware flag.

Code: (Javascript)
function getFlashVersion() {
try {
try {
var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
try {
axo.AllowScriptAccess = 'always';
} catch (e) {
return '6,0,0';
}
} catch (e) {}
return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
} catch (e) {
try {
if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
}
} catch (e) {}
}
return '0,0,0';
}
function getMainFlashVersion() {
return getFlashVersion().split(',').shift();
};


Hope it helps you :)