復制代碼 代碼如下:
//檢測非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());