js 非IE火狐插件检测

时间:2023-01-20 08:13:15

js检测代码Html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Plugins Test</title>
<script type="text/javascript">
function getPluginName(){
var info = "";
var plugins = navigator.plugins;
if (plugins.length>) {
for (i=; i < navigator.plugins.length; i++ ) {
info += navigator.plugins[i].name+"<br/>";
}
}
document.getElementById("divPlugins").innerHTML=info;
}
function getFFPlugins()
{
var info="";
var plugins=navigator.mimeTypes;
if(plugins.length>){
for(i=;i<navigator.mimeTypes.length;i++){
info+=navigator.mimeTypes[i].type+":"+navigator.mimeTypes[i].description+"<br/>";
}
document.getElementById("divFFPlugins").innerHTML=info;
}
}
window.onload=function(){
getPluginName();
getFFPlugins();
}
</script>
</head>
<body>
<div>this is a chrome test.</div>
<div id="divPlugins"></div>
<hr/>
<div id="divFFPlugins"></div>
</body>

今天检测遇到一个问题,值得注意,检测mimeTypes时,是区分大小写的。无论你火狐插件里是大写还是小写,在chrome中都是小写,所以在做插件的时候值得注意,最好全部是小写。