我的团队想要为Firefox/Chrome/IE构建一个“插件”。
如何使用JavaScript检测是否安装了此插件(而不是扩展)?
我希望有一段JavaScript代码,可以检测某个特定的插件是否已安装。如果已安装,则返回true,否则返回false。
例如...如何获取插件列表,然后循环遍历以查看是否有一个匹配我的插件名称?如果匹配,则返回1。
我的团队想要为Firefox/Chrome/IE构建一个“插件”。
如何使用JavaScript检测是否安装了此插件(而不是扩展)?
我希望有一段JavaScript代码,可以检测某个特定的插件是否已安装。如果已安装,则返回true,否则返回false。
例如...如何获取插件列表,然后循环遍历以查看是否有一个匹配我的插件名称?如果匹配,则返回1。
navigator.plugins
将有一个插件数组,您可以检查。
这适用于Firefox、Chrome和IE(至少是版本8,我没有更低版本进行测试)
这是Webkit中数组的样子:
<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>
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>")
navigator.plugins
的能力? - ceejayoz