Is It Possible To Detect If A Plugin Is Activated Or Not Through Javascript?
This way I would normally detect plugins, such as Flash Player: for (var el in navigator.plugins) { if (navigator.plugins[el].name && navigator.plugins[el].name
Solution 1:
Both of the other solutions work to find out if a plugin is installed AND is enabled.
There is currently no way to find out if the plugin is installed but is disabled. Navigator.plugins
does not contain disabled plugins which are still installed.
Solution 2:
navigator.plugins
is an array, so you'd use for each
in modern browsers and iterate with an index otherwise:
functionpluginActive(pname) {
for (var i = 0;i < navigator.plugins.length;i++) {
if (navigator.plugins[i].name.indexOf(pname) != -1) {
returntrue;
}
}
returnfalse;
}
console.log("Flash plugin " +
(pluginsActive("Shockwave Flash") ? "active" : "not present"));
You can not distinguish plugins that are disabled and not present. Bear in mind that you may have to restart your browser before plugin activation / deactivation takes effect.
Solution 3:
If the plugin in question is disabled, it won't appear in navigator.plugins
or be otherwise exposed to the page.
Post a Comment for "Is It Possible To Detect If A Plugin Is Activated Or Not Through Javascript?"