检测IE插件
function hasIEPlugin(name){
try{
new ActiveXObject(name);
return true;
}catch(ex){
return false;
}
};
console.log(hasIEPlugin('ShockwaveFlash.ShockwaveFlash'));
检测非IE的插件
function hasPlugin(name){
name = name.toLowerCase();
for(var i=;i<navigator.plugins.length;i++){
if(navigator.plugins[i].name.toLowerCase().indexOf(name) > -){
return true;
}
}
return false;
} console.log(hasPlugin('flash'));
◆由上可见IE的插件名有点特殊,按需百度吧
◆暂不了解遍历IE插件的方法,非IE游览器可用for length 遍历
封装
function detectPlugin(name){
var borwser = navigator.appname;
if(borwser == 'Microsoft Internet Explorer'){
try{
new ActiveXObject(name);
return true;
}catch(ex){
return false;
}
}else{
name = name.toLowerCase();
for(var i=;i<navigator.plugins.length;i++){
if(navigator.plugins[i].name.toLowerCase().indexOf(name) > -){
return true
}
}
return false
}
} console.log(detectPlugin('flash'));
◆这个有待研究吧,JS高设3 P213