Is it possible to determine if a plugin is activated or not via JavaScript?

Thus, I would usually detect plugins such as Flash Player :

for (var el in navigator.plugins) { if (navigator.plugins[el].name && navigator.plugins[el].name.toLowerCase().indexOf('shockwave') !== -1) { console.log(navigator.plugins[el]); } } 

I am not looking for a cross-browser solution or want to check if this is correct or not. What is the way to check if this plugin is active or not?

+3
source share
3 answers

Both other solutions work to find out if the AND plugin is installed.

There is currently no way to find out if the plugin is installed but disabled. Navigator.plugins does not contain disabled plugins that are still installed.

+6
source

navigator.plugins is an array, so you use for each in modern browsers and iterate with the index differently:

 function pluginActive(pname) { for (var i = 0;i < navigator.plugins.length;i++) { if (navigator.plugins[i].name.indexOf(pname) != -1) { return true; } } return false; } console.log("Flash plugin " + (pluginsActive("Shockwave Flash") ? "active" : "not present")); 

You cannot distinguish plugins that are disabled and not present. Keep in mind that you may have to restart your browser before activating / deactivating the plugin.

+1
source

If the plug-in is disabled, it will not be displayed in navigator.plugins or it will otherwise be displayed on the page.

0
source

Source: https://habr.com/ru/post/1265316/


All Articles