Home > Web Front-end > JS Tutorial > body text

JavaScript study notes (17) Detecting browser plug-in code_Basic knowledge

WBOY
Release: 2016-05-16 17:52:28
Original
962 people have browsed it
Copy code The code is as follows:

//Detect non-IE browser plug-in function
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;
}

//Detect IE browser Plug-in function
function hasIEPlugin(name) {
try {
new ActiveXObject(name);
return true;
}
catch (ex) {
return false;
}
}
//Detect Flash in all browsers
function hasFlash() {
var result = hasPlugin("Flash");
if (!result) {
result = hasIEPlugin("ShockwaveFlash.ShockwaveFlash");
}
return result;
}
//Detect QuickTime in all browsers
function hasQuickTime() {
var result = hasPlugin("QuickTime");
if (!result) {
result = hasIEPlugin("QuickTime.QuickTime");
}
return result;
}

alert(hasFlash());
alert(hasQuickTime());
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template