实现代码如下:

//检测非IE浏览器插件函数
function hasPlugin(name) {
name = name.toLowerCase();
for (var i=0 ; i < navigator.plugins.length ; i++ ) {
if (navigator.plugins[i].name.toLowerCase().indexOf(name) >-1) {
return true;
}
}
return false;
}

//检测IE浏览器插件函数
function hasIEPlugin(name) {
try {
new ActiveXObject(name);
return true;
}
catch (ex) {
return false;
}
}
//检测所有浏览器中的Flash
function hasFlash() {
var result = hasPlugin("Flash");
if (!result) {
result = hasIEPlugin("ShockwaveFlash.ShockwaveFlash");
}
return result;
}
//检测所有浏览器中的QuickTime
function hasQuickTime() {
var result = hasPlugin("QuickTime");
if (!result) {
result = hasIEPlugin("QuickTime.QuickTime");
}
return result;
}

alert(hasFlash());
alert(hasQuickTime());

以上就是【JavaScript学习日志(十七) 检测浏览器插件代码】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)
发表我的评论

最新评论

  1. 暂无评论