判断网页浏览器内嵌Flash版本(JS)

 1 
 2 function flashChecker()
 3 {
 4 var hasFlash=0;         //是否安装了flash
 5 var flashVersion=0; //flash版本
 6 var isIE=/*@cc_on!@*/0;      //是否IE浏览器
 7 
 8 if(isIE)
 9 {
10 var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); 
11 if(swf) {
12 hasFlash=1;
13 VSwf=swf.GetVariable("$version");
14 flashVersion=parseInt(VSwf.split(" ")[1].split(",")[0]); 
15 }
16 }else{
17 if (navigator.plugins && navigator.plugins.length > 0)
18 { 
19 var swf=navigator.plugins["Shockwave Flash"];
20     if (swf)
21      {
22 hasFlash=1;
23         var words = swf.description.split(" ");
24         for (var i = 0; i < words.length; ++i)
25 {
26             if (isNaN(parseInt(words[i]))) continue;
27             flashVersion = parseInt(words[i]);
28 }
29     }
30 }
31 }
32 return {f:hasFlash,v:flashVersion};
33 }
34 
35 var fls=flashChecker();
36 var s="";
37 if(fls.f) document.write("您安装了flash,当前flash版本为: "+fls.v+".x");
38 else document.write("您没有安装flash"); 
posted @ 2012-11-23 14:51  易木  阅读(260)  评论(0编辑  收藏  举报