This article mainly introduces how to obtain the flash version number by using javascript. It analyzes the method of javascript in the form of an example to determine whether a user has installed Flash or obtained the Flash version number, which has some practical value, for more information about how to use javascript to obtain the flash version, see the following example. Share it with you for your reference. The specific analysis is as follows:
Next we will introduce two js functions to determine whether flash is installed. If flash is installed, we will get the flash version number and give a prompt.
Example 1
Obtain the version number of each browser. To obtain a specific version number
The Code is as follows:
Function flashChecker (){
Var hasFlash = 0; // whether flash is installed
Var flashVersion = 0; // flash version
Var isIE =/* @ cc_on! @ */0; // whether the browser is Internet Explorer
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 have not installed flash ");
Example 2
The Code is 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 + ). * $/, "$1 "));
}
} 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 version: '+ flashVer );
} Else {
Document. write ('you have not installed flash player ');
}
I hope this article will help you design javascript programs.