Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript - get detailed information about the browser

Basically I'm looking for something to give me easy access to information like useragentstring.com, but in JS, without me parsing the user agent and looking for each possible bit of text. The object could be something like this:

browser      = UserAgent.Browser;                // Chrome
browserVer   = UserAgent.BrowserVersion;         // 5.0.342.9
os           = UserAgent.OperatingSystem;        // Windows NT
osVer        = UserAgent.OperatingSystemVersion; // 6.1
layoutEng    = UserAgent.LayoutEngine;           // WebKit
layoutEngVer = UserAgent.LayoutEngineVersion;    // 533.2

Does something similar to that exist or do I have to write one myself? Writing yet another user agent parser doesn't seem that easy with all those impersonations going back to the dark ages of the web.

Specifically I'm looking for something that doesn't just split the user agent into parts and give them to me, because that's as useless as the user agent itself; instead it should parse the user agent and recognize the engine, browser, OS, etc. and return the concrete parts only, as in the example.

like image 634
CMircea Avatar asked Apr 08 '10 10:04

CMircea


People also ask

How do you find operating system details with JavaScript in browser?

To detect the operating system on the client machine, one can simply use navigator. appVersion or navigator. userAgent property. The Navigator appVersion property is a read-only property and it returns a string which represents the version information of the browser.

What is navigator appName in JavaScript?

It is used for returning the name of the browser. It is a read-only property and the values returned by it varies from browsers to browsers. it returns a string which represents the name of the browser.

How can you detect the client's browser name in JavaScript?

You can use the navigator. appName and navigator. userAgent properties. The userAgent property is more reliable than appName because, for example, Firefox (and some other browsers) may return the string "Netscape" as the value of navigator.

What is window Navigator userAgent?

The userAgent property returns the user-agent header sent by the browser to the server. The userAgent property is read-only. The value returned, contains information about the browser name, version and platform. The web specification suggests that browsers should provide as little header information as possible.


1 Answers

This should help you, have a look of the values for the following:

navigator["appCodeName"]
navigator["appName"]
navigator["appMinorVersion"]
navigator["cpuClass"]
navigator["platform"]
navigator["plugins"]
navigator["opsProfile"]
navigator["userProfile"]
navigator["systemLanguage"]
navigator["userLanguage"]
navigator["appVersion"]
navigator["userAgent"]
navigator["onLine"]
navigator["cookieEnabled"]
navigator["mimeTypes"]

var x = '';
for(var p in navigator){
   try {
      x += p + '=' + navigator[p] + "\n";
      console.log(x);
   }
   catch(e) {
       console.error(e);
   }
}
like image 81
jerjer Avatar answered Sep 17 '22 16:09

jerjer