Search code examples
javascriptgoogle-chromenpapi

Detect version of the plugin in Chrome browser


I have NPAPI plugin and I want to detect its version before I embed it into web page. If version is not the latest one I want to show some message that asks users to update the plugin.

Now it's implemented in the following way

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
}

The problem is that navigator.plugins["myplugin"].version works fine in Firefox but not in Chrome. Chrome doesn't expose version property. I can add my own property in NPAPI code, but I don't see the way I can use it before embedding the plugin into page.

Is there any workaround?

Thanks in advance, Andrew


Solution

  • I see a lot of plugins have version information in either the name or the description. You should be able to access that information before the embed.