剑痴乎

  • 首页
  • 文章分类
    • 音视频
    • WebRTC
    • 编程之美
    • Linux
    • Windows
    • 生活点滴
    • 校园生活
  • 参考
    • API参考
    • 实用工具
    • 测试音视频
    • 文档
  • 留言板
  • 关于
剑痴乎
代码为剑,如痴如醉
  1. 首页
  2. Web
  3. 正文

浏览器获取所安装插件列表

2018年7月5日 2959点热度 4人点赞 0条评论

最近需要一个功能,浏览器能够判断我们的插件是否安装,没安装的话提示用户安装。查了下,只要我们插件成功注册到火狐浏览器中,可通过navigator.plugins数据获取所有安装的插件信息。

如下图是我通过该方法在火狐上获取的插件信息:

我也测了下Chrome上获取的信息:

Edge浏览器情况:

可以看到不同浏览器都支持这一方法,但是获取的插件信息是不一样的。虽然我的Chrome与Edge不支持插件安装,但是本身内置了几个插件,比如pdf阅读与flash播放器,通过该方法都可以看到,所以不能说现在的浏览器完全没有插件。获取插件信息代码如下:

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE HTML>
<html>
<body>
 
<script>
   var pluginsLength = navigator.plugins.length;
 
   document.body.innerHTML = pluginsLength + " Plugin(s)<br>"
  + '<table id="pluginTable"><thead>'
  +'<tr><th>Name</th><th>Filename</th><th>description</th><th>version</th></tr>'
  +'</thead><tbody></tbody></table>';
 
var table = document.getElementById('pluginTable');
 
for(var i = 0; i < pluginsLength; i++) {
  let newRow = table.insertRow();
  newRow.insertCell().textContent = navigator.plugins[i].name;
  newRow.insertCell().textContent = navigator.plugins[i].filename;
  newRow.insertCell().textContent = navigator.plugins[i].description;
  newRow.insertCell().textContent = navigator.plugins[i].version?navigator.plugins[i].version:"";
}
</script>
</body>
</html>

参考

navigator.plugins使用:https://developer.mozilla.org/en-US/docs/Web/API/NavigatorPlugins/plugins

本作品采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2022年3月27日

Jeff

管理员——代码为剑,如痴如醉

打赏 点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。

文章目录
  • 参考
相关文章
  • FireBreath插件IE浏览器中文字符乱码问题
  • web页面npapi插件资源管理问题
  • 基于FireBreath的npapi插件在Firefox下的调试

COPYRIGHT © 2025 jianchihu.net. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang