Detecting Plug-ins
The following code use the the plugins array to determine the plugins.
Each item in the plugins array contains:
Name | Meaning |
---|---|
name | The name of the plug-in |
description | The description of the plug-in |
filename | The filename for the plug-in |
length | The number of MIME types handled by this plug-in |
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
<script>
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;
}
function hasIEPlugin(name){
try {
new ActiveXObject(name);
return true;
} catch (ex){
return false;
}
}
document.writeln(hasPlugin("Flash"));
document.writeln(hasIEPlugin("ShockwaveFlash.ShockwaveFlash"));
</script>
</body>
</html>