检测浏览器是否安装FLASH插件

    var iFlash = null;
var version = null;
var isIE = navigator.userAgent.toLowerCase().indexOf("msie") != -1
if(isIE){
//for IE

if (window.ActiveXObject) {
var control = null;
try {
control = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
} catch (e) {
iFlash = false;
}
if (control) {
iFlash = true;
version = control.GetVariable('$version').substring(4);
version = version.split(',');
version = parseFloat(version[0] + '.' + version[1]);
alert("FLASH版本号:"+version)
}
}
}else{
//for other
if (navigator.plugins) {
for (var i=0; i < navigator.plugins.length; i++) {
if (navigator.plugins[i].name.toLowerCase().indexOf("shockwave flash") >= 0) {
iFlash = true;
version = navigator.plugins[i].description.substring(navigator.plugins[i].description.toLowerCase().lastIndexOf("Flash ") + 6, navigator.plugins[i].description.length);
}
}
}
}
if(iFlash){
alert(version)
}else{
alert("您的浏览器未安装FLASH插件");
}
posted @ 2012-02-20 17:21  Scool.Miss  阅读(1031)  评论(1编辑  收藏  举报