首页 > web前端 > js教程 > 正文

借助JavaScript脚本判断浏览器Flash Player信息的方法_javascript技巧

WBOY
发布: 2016-05-16 16:42:10
原创
970 人浏览过

今天研究了点Flex技术,做了一个小的Demo,在测试时发现经常报错,网上一查发现是浏览器Flash Player版本较低造成(需要10及其以上的版本)的,对此总结了一下借助JavaScript脚本判断浏览器Flash Player信息的方法:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<title>JavaScript判断浏览器Flash Player信息</title> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
<script type="text/javascript"> 
function checkFlashPlayer(){ 
var hasFlashPlayer=0; //判断是否安装了Flash Player 
var flashPlayerVersion=0; //Flash Player版本 
if(document.all){ 
var shockWaveFlash = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); 
if(shockWaveFlash) { 
hasFlashPlayer=1; 
flashPlayerVersion=parseInt(shockWaveFlash.GetVariable("$version").split(" ")[1].split(",")[0]); 
} 
}else if (navigator.plugins && navigator.plugins.length > 0){ 
var shockWaveFlash=navigator.plugins["Shockwave Flash"]; 
if (shockWaveFlash){ 
hasFlashPlayer=1; 
var descriptionInfo = shockWaveFlash.description.split(" "); 
for (var i = 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("您的Flash Player版本过低,立即升级Flash Player版本?")){ 
window.location.href="http://get.adobe.com/cn/flashplayer/" rel="external nofollow" rel="external nofollow" ; 
} 
}else{ 
alert("您安装了Flash Player,当前Flash Player版本号为:"+checkFlashPlayer().flashPlayerVersion+"。"); 
} 
}else{ 
if(confirm("您没有安装Flash Player,立即安装?")){ 
window.location.href="http://get.adobe.com/cn/flashplayer/" rel="external nofollow" rel="external nofollow" ; 
} 
} 
</script> 
</head> 

<body> 
</body> 
</html>
登录后复制

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!