How to obtain the flash version number using javascript

Source: Internet
Author: User

How to obtain the flash version number using javascript

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 ');
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.