4

How can you detect if a browser supports NPAPI from JavaScript? Not all of them do, and whilst I could rely on the user-agent I'd much rather do it a more reliable way if one exists.

Unfortunately, I can't simply detect if my plug-in has loaded or not, as it may be that the plugin simply isn't installed yet on a supported browser.

Thanks.

Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
gdt
  • 1,822
  • 17
  • 19

2 Answers2

1

There is no JS API for this, but basically all desktop browsers except IE-/Trident-based ones and ChromeOS support NPAPI.

You can find out wether your plugin is installed by checking navigator.plugins.

Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
  • "Non-desktop" is a pretty big exception at this point though. Also, ChromeOS doesn't support NPAPI, and there are non-IE Trident-based browsers like Avant and Maxthon. So it's not exactly trivial to get a UA list right. – smorgan Feb 13 '13 at 11:10
  • Ok, ChromeOS complicates things. While there are other questions on mobile/IE/... detection, some UA check on *"Trident"*, IE, *"Mobi"* and *"CrOS"* should probably work at the moment? – Georg Fritzsche Feb 13 '13 at 16:17
  • It's shame there's no API. Luckily, my NPAPI plugin is 32bit Windows only, so I can reasonably reliably check for a UA that contains "Windows NT" and not ("Win64" or "Trident"). – gdt Feb 14 '13 at 16:20
  • 1
    Note that this has been further complicated by Chrome deprecating NPAPI: http://stackoverflow.com/q/28766423/230167 – Bryan Downing May 27 '15 at 21:46
-2

If you want to check whether java plugins are enabled or not in the browser then you should use the navigator.javaEnabled(). It will work in chrome.

mohiz tank
  • 17
  • 3