是否可以通过JavaScript检测插件是否被激活?
问题描述:
这样我通常会检测插件,例如 Flash Player :
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.toLowerCase().indexOf('shockwave') !== -1) {
console.log(navigator.plugins[el]);
}
}
我不是在寻找跨浏览器解决方案或者想要测试它是否正确。测试此插件是否处于活动状态的方法是什么?
I'm not looking for a cross-browser solution or want to test if it is the right way or not. What is the way to test if this plugin is active or not?
答
其他两个解决方案都可以找出是否存在插件已安装并已启用。
Both of the other solutions work to find out if a plugin is installed AND is enabled.
目前无法确定插件是否已安装但已被禁用。 Navigator.plugins
不包含仍然安装的已禁用插件。
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.