jldupont
jldupont

Reputation: 96836

Determine which OS from Javascript

Is there a way to determine which OS is the browser being run on?

I have an NPAPI plugin which, at the moment, can only function on Linux and I would like to alert users if they try using the plugin on !Linux machines.

Upvotes: 0

Views: 551

Answers (3)

bobince
bobince

Reputation: 536715

navigator.platform.substring(0, 5)==='Linux'

Opera reports only Linux for navigator.platform. Mozilla and Chromium also give the arch name, eg. Linux i686 or Linux x86_64, which may be of interest if your plugin isn't available for all architectures.

If you want to also allow other Unix platforms which might possibly be able to run an ELF NPAPI plugin, you could instead look for the substring X11 in navigator.platform.appVersion, perhaps, though this is a bit woolly.

Upvotes: 1

sheats
sheats

Reputation: 34692

PPK has a script over at quirksmode.com that will probably work for you.

Upvotes: 5

Chris
Chris

Reputation: 3529

A simple google search turned up the following: http://www.javascripter.com/faq/operatin.htm

Upvotes: 0

Related Questions