This example describes how JavaScript gets the Flash version number. Share to everyone for your reference. The specific analysis is as follows:
Here we will introduce two JS functions to determine whether the user installed Flash, if the Flash is installed to obtain the Flash version number and give a hint.
Example 1
Get the version number of each browser, if you need to get a specific version number
Copy Code code as follows:
function Flashchecker () {
var hasflash = 0; Whether Flash is installed
var flashversion = 0; Flash version
var isie =/* @cc_on!@*/0; Whether IE browser
if (Isie) {
var swf = new ActiveXObject (' Shockwaveflash.shockwaveflash ');
if (SWF) {
Hasflash = 1;
flashversion = swf. GetVariable ("$version");
}
} else {
if (navigator.plugins && navigator.plugins.length > 0) {
var swf = navigator.plugins["Shockwave Flash"];
if (SWF) {
Hasflash = 1;
Flashversion = Swf.description.split ("");
}
}
}
return {
F:hasflash,
V:flashversion
};
}
var FLs = Flashchecker ();
if (FLS.F) document.write ("You have installed Flash, the current Flash version is:" + fls.v + ". X");
else document.write ("You do not have Flash installed");
Example 2
Copy Code code as follows:
function Getflashversion () {
var flashver = NaN;
var ua = navigator.useragent;
if (window. ActiveXObject) {
var swf = new ActiveXObject (' Shockwaveflash.shockwaveflash ');
if (SWF) {
Flashver = Number (swf. GetVariable (' $version '). Split (') [1].replace (/,/g, '. '). Replace (/^ (d+.d+). *$/, "$"));
}
} else {
if (navigator.plugins && navigator.plugins.length > 0) {
var swf = navigator.plugins[' Shockwave Flash '];
if (SWF) {
var arr = swf.description.split (');
for (var i = 0, len = arr.length i < len; i++) {
var ver = number (arr[i]);
if (!isnan (ver)) {
Flashver = ver;
Break
}
}
}
}
}
return flashver;
}
var flashver = getflashversion ();
if (!isnan (Flashver)) {
document.write (' current Flash Player's version: ' + Flashver ');
} else {
document.write (' You have not installed Flash Player ');
}
I hope this article will help you with your JavaScript programming.