JCHub

  • Home
  • Category
    • A/V
    • WebRTC
    • Beauty of Programming
    • Linux
    • Windows
    • Moments of Life
    • Campus Life
  • Reference
    • API Reference
    • Utilities
    • AV Test
    • Doc
  • Message Board
  • About
JCHub
Code as My Sword, Lost in Obsession
  1. Main page
  2. Web
  3. Main content

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

2018年7月5日 3256hotness 4likes 0comments

最近需要一个功能,浏览器能够判断我们的插件是否安装,没安装的话提示用户安装。查了下,只要我们插件成功注册到火狐浏览器中,可通过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

This article is licensed with Creative Commons Attribution-NonCommercial-No Derivatives 4.0 International License
Tag: Nothing
Last updated:2022年3月27日

Jeff

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

Tip the author Like
< Last article
Next article >

Comments

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

文章目录
  • 参考
Related Posts
  • wordpress更新6.8.1报错
  • FireBreath插件IE浏览器中文字符乱码问题
  • web页面npapi插件资源管理问题
  • 基于FireBreath的npapi插件在Firefox下的调试
Categories

COPYRIGHT © 2026 jianchihu.net. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang