2011-03-04 58 views
11

我想知道是否有辦法檢測不同瀏覽器上安裝的插件。 到目前爲止,我發現你可以通過嘗試猜測是否存在chrome://path/to/some/plugin/image.gif來「檢測」Firefox上的插件。在不同的瀏覽器下檢測已安裝的插件?

這對Firefox的代碼如下所示:

<img src="chrome://firebug/content/blank.gif" onload="var a=document.getElementById('FireBug'); a.innerHTML = 'You are using FireBug';" style="visibility:hidden"> 
<div id="FireBug">You are not using FireBug</div> 

我很感興趣如何做代碼看起來在IE(對我來說更重要的),如果還有其他的方法來完成這項任務的其他瀏覽器太?

我想知道,因爲我有一個白癡客戶端聲稱他沒有安裝插件,雖然我99.99%肯定他有。問題是,這些插件中的一部分正在破壞我寫的一個網站管理控制面板的一部分。

無論如何,我會很高興聽到任何提示,技巧和解決方法等,爲獲得流行的瀏覽器(FF,即,歌劇,鉻,Safari瀏覽器):)

回答

20

該代碼將列出安裝在瀏覽器的所有插件

<html> 
<body> 
<div id="example"></div> 
<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> 
</body> 
</html> 
+1

我很抱歉花了sooooooooo很長的時間來接受這個答案。當時這不是一個標準,只能在Firefox和/或Chrome上運行。現在似乎廣泛支持,所以我會接受你的答案。 :) – tftd 2016-02-15 16:12:40

+0

@tftd它的一切都好。感謝您接受我的回答。 – Hackaholic 2016-02-15 19:22:54

+0

不適用於Firefox 48(在OSX上)。 – DanFromGermany 2016-09-14 10:26:14

1

你可以試試這個的插件列表:http://www.sliceratwork.com/detect-installed-browser-plugins-using-javascript

...但是這不會像檢測螢火蟲,無腳本等瀏覽器插件

該腳本似乎只檢測了以下插件: -

  • 的Java
  • 3D標記語言的Web
  • 的DjVu
  • 閃存
  • 谷歌通話
  • Acrobat Reader軟件
  • 的QuickTime
  • 的RealPlayer
  • SVG瀏覽器
  • 衝擊波
  • 的Silverlight
  • Skype的
  • VLC
  • 的Windows Media Player
  • Xara
+0

我會嘗試,但我不認爲這會幫助我:/ – tftd 2011-03-04 15:01:31

+4

鏈接不起作用。 – 2013-12-05 09:31:52

2

此代碼會給你所有的信息你需要:

<HTML> 
<HEAD> 
<TITLE>About Plug-ins</TITLE> 
</HEAD> 
<BODY> 
<SCRIPT language="javascript"> 
numPlugins = navigator.plugins.length; 

if (numPlugins > 0) 
    document.writeln("Installed plug-ins"); 
else 
document.writeln("No plug-ins are installed."); 

for (i = 0; i < numPlugins; i++) { 
plugin = navigator.plugins[i]; 
document.write("<center><font size=+1><b>"); 
document.write(plugin.name); 
document.writeln("</b></font></center><br>"); 
document.writeln("<dl>"); 
document.writeln("<dd>File name:"); 
document.write(plugin.filename); 
document.write("<dd><br>"); 
document.write(plugin.description); 
document.writeln("</dl>"); 
document.writeln("<p>"); 
document.writeln("<table border=1 >"); 
document.writeln("<tr>"); 
document.writeln("<th width=20%>Mime Type</th>"); 
document.writeln("<th width=50%>Description</th>"); 
document.writeln("<th width=20%>Suffixes</th>"); 
document.writeln("<th>Enabled</th>"); 
document.writeln("</tr>"); 
numTypes = plugin.length; 
for (j = 0; j < numTypes; j++) 
{ 
    mimetype = plugin[j]; 

    if (mimetype){ 
    enabled = "No"; 
    enabledPlugin = mimetype.enabledPlugin; 
    if (enabledPlugin && (enabledPlugin.name == plugin.name)) 
    enabled = "Yes"; 
    document.writeln("<tr align=center>"); 
    document.writeln("<td>"); 
    document.write(mimetype.type); 
    document.writeln("</td>"); 
    document.writeln("<td>"); 
    document.write(mimetype.description); 
    document.writeln("</td>"); 
    document.writeln("<td>"); 
    document.write(mimetype.suffixes); 
    document.writeln("</td>"); 
    document.writeln("<td>"); 
    document.writeln(enabled); 
    document.writeln("</td>"); 
    document.writeln("</tr>"); 
    } 
} 
document.write("</table>"); 
} 
</SCRIPT> 
</BODY> 
</HTML>