萬盛學電腦網

 萬盛學電腦網 >> 腳本專題 >> javascript >> javascript檢查浏覽器是否支持flash的實現代碼

javascript檢查浏覽器是否支持flash的實現代碼

 

<script> 02   function flashChecker() { 03     var hasFlash = 0; //是否安裝了flash 04     var flashVersion = 0; //flash版本 05     if (document.all) { 06       var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); 07       if (swf) { 08         hasFlash = 1; 09         VSwf = swf.GetVariable("$version"); 10         flashVersion = parseInt(VSwf.split(" ")[1].split(",")[0]); 11       } 12     } else { 13       if (navigator.plugins && navigator.plugins.length > 0) { 14         var swf = navigator.plugins["Shockwave Flash"]; 15         if (swf) { 16           hasFlash = 1; 17           var words = swf.description.split(" "); 18           for (var i = 0; i < words.length; ++i) { 19             if (isNaN(parseInt(words[i]))) continue; 20             flashVersion = parseInt(words[i]); 21           } 22         } 23       } 24     } 25     return { f: hasFlash, v: flashVersion }; 26   } 27   var fls = flashChecker(); 28   var s = ""; 29   if (fls.f) document.write("您安裝了flash,當前flash版本為: " + fls.v + ".x"); 30   else document.write("您沒有安裝flash");  31 </script>
copyright © 萬盛學電腦網 all rights reserved