借助JavaScript脚本判断浏览器Flash Player信息的方法
今天研究了点Flex技术,做了一个小的Demo,在测试时发现经常报错,网上一查发现是浏览器FlashPlayer版本较低造成(需要10及其以上的版本)的,对此总结了一下借助JavaScript脚本判断浏览器FlashPlayer信息的方法:
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
<html>
<head>
<title>JavaScript判断浏览器FlashPlayer信息</title>
<metahttp-equiv="content-type"content="text/html;charset=UTF-8">
<scripttype="text/javascript">
functioncheckFlashPlayer(){
varhasFlashPlayer=0;//判断是否安装了FlashPlayer
varflashPlayerVersion=0;//FlashPlayer版本
if(document.all){
varshockWaveFlash=newActiveXObject('ShockwaveFlash.ShockwaveFlash');
if(shockWaveFlash){
hasFlashPlayer=1;
flashPlayerVersion=parseInt(shockWaveFlash.GetVariable("$version").split("")[1].split(",")[0]);
}
}elseif(navigator.plugins&&navigator.plugins.length>0){
varshockWaveFlash=navigator.plugins["ShockwaveFlash"];
if(shockWaveFlash){
hasFlashPlayer=1;
vardescriptionInfo=shockWaveFlash.description.split("");
for(vari=0;i<descriptionInfo.length;++i){
if(isNaN(parseInt(descriptionInfo[i]))){
continue;
}
flashPlayerVersion=parseInt(descriptionInfo[i]);
}
}
}
return{hasFlashPlayer:hasFlashPlayer,flashPlayerVersion:flashPlayerVersion};
}
if(checkFlashPlayer().hasFlashPlayer){
if(checkFlashPlayer().flashPlayerVersion<=10){
if(confirm("您的FlashPlayer版本过低,立即升级FlashPlayer版本?")){
window.location.href="http://get.adobe.com/cn/flashplayer/"rel="externalnofollow"rel="externalnofollow";
}
}else{
alert("您安装了FlashPlayer,当前FlashPlayer版本号为:"+checkFlashPlayer().flashPlayerVersion+"。");
}
}else{
if(confirm("您没有安装FlashPlayer,立即安装?")){
window.location.href="http://get.adobe.com/cn/flashplayer/"rel="externalnofollow"rel="externalnofollow";
}
}
</script>
</head>
<body>
</body>
</html>