javascript学习笔记(十七) 检测浏览器插件代码
时间:2021-03-01 13:45:23|栏目:JavaScript代码|点击: 次
复制代码 代码如下:
//检测非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());
上一篇:详解promise.then,process.nextTick, setTimeout 以及 setImmediate的执行顺序
栏 目:JavaScript代码
本文标题:javascript学习笔记(十七) 检测浏览器插件代码
本文地址:http://www.codeinn.net/misctech/72439.html






