【问题标题】:How do I detect a custom plugin in Firefox/IE/Chrome?如何在 Firefox/IE/Chrome 中检测自定义插件?
【发布时间】:2010-12-25 21:52:14
【问题描述】:

我的团队想要为 firefox/chrome/IE 构建一个“插件”。 如何使用 javascript 来检测是否安装了这个插件(不是扩展)?

我想要一个 javascript 可以检测是否安装了某个插件。如果安装返回 true,否则返回 false。

例如...如何获取插件列表,然后循环查看其中一个是否与我的插件名称匹配?如果匹配,则返回 1。

【问题讨论】:

    标签: c# javascript c++ browser plugins


    【解决方案1】:

    navigator.plugins 会有一系列插件供您查看。

    这适用于 Firefox、Chrome 和 IE(至少是 8 版,我没有更低的版本来测试)

    这是数组在 webkit 中的样子:

    【讨论】:

    • 浏览器 DOM 功能真的发展了很多。不错。
    • 你好,马特,我尝试使用 navigator.plugins 来检测客户端计算机上安装的插件。但它不适用于 IE。你能指导我吗?
    【解决方案2】:

    您可以通过此 javascript 代码获取浏览器插件:

    <script type="text/javascript">
    var x=navigator.plugins.length; // store the total no of plugin stored 
    var txt="Total plugin installed: "+x+"<br/>";
    txt+="Available plugins are->"+"<br/>";
    for(var i=0;i<x;i++)
    {
      txt+=navigator.plugins[i].name + "<br/>"; 
    }
    document.getElementById("example").innerHTML=txt;
    </script>
    <br/>
    <script>
    

    【讨论】:

      【解决方案3】:
      solved:
      
      document.writeln("<TABLE BORDER=1><TR VALIGN=TOP>",
         "<TH ALIGN=left>i",
         "<TH ALIGN=left>name",
         "<TH ALIGN=left>filename",
         "<TH ALIGN=left>description",
         "<TH ALIGN=left># of types</TR>")
      for (i=0; i < navigator.plugins.length; i++) {
         document.writeln("<TR VALIGN=TOP><TD>",i,
            "<TD>",navigator.plugins[i].name,
            "<TD>",navigator.plugins[i].filename,
            "<TD>",navigator.plugins[i].description,
            "<TD>",navigator.plugins[i].length,
            "</TR>")
      }
      document.writeln("</TABLE>")
      

      【讨论】:

      • 也许你可以接受@Matt 的回答,他指出了navigator.plugins 的能力?
      • 我试过了,但它不会让我。由于某种原因,支票被锁定
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-08
      • 2022-12-24
      • 1970-01-01
      • 2011-02-27
      • 1970-01-01
      相关资源
      最近更新 更多