我有 NPAPI 插件,我想在将其嵌入网页之前检测它的版本。如果版本不是最新版本,我想显示一些要求用户更新插件的消息。
现在它通过以下方式实现
if (navigator.mimeTypes && navigator.mimeTypes["application/myplugin"]) {
{
// some code here
if(navigator.plugins["myplugin"] && navigator.plugins["myplugin"].version >= latest_version) {
// we have the latest version (embed the plugin into web page)
document.write ("<object id='plugin'><embed ....></object>");
} else {
document.write ("Show message here");
}
// some code
}
问题是它navigator.plugins["myplugin"].version
在 Firefox 中运行良好,但在 Chrome 中却不行。Chrome 不公开version
属性。我可以在 NPAPI 代码中添加我自己的属性,但在将插件嵌入页面之前我看不到我可以使用它的方式。
有什么解决方法吗?
在此先感谢,安德鲁