检测flash是否安装及版本号
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>flash检测版本</title> </head> <body> <script type="text/javascript"> function flashChecker() { var hasFlash = 0; //是否安装了flash var flashVersion = 0; //flash版本 var isIE = /*@cc_on!@*/ 0; //是否IE浏览器 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("您安装了flash,当前flash版本为: " + fls.v + ".x"); else document.write("您没有安装flash"); 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(',,,,,,,当前flash player 的版本:' + flashVer); } else { document.write('您尚未安装flash播放器'); } </script> </body> </html>
效果如下: