JavaScript Window Navigator

the window.navigator object contains information about the visitor's browser.

Window Navigator

window.navigator objects can be written without the window prefix.


txt = "<p>Browser code name: "+ navigator.appCodeName + "</p>";
txt+= "<p>Browser name: "+ navigator.appName + "</p>";
txt+= "<p>Browser version: "+ navigator.appVersion + "</p>";
txt+= "<p>Enable Cookies: "+ navigator.cookieEnabled + "</p>";
txt+= "<p>Hardware platform: "+ navigator.platform + "</p>";
txt+= "<p>User Agent: "+ navigator.userAgent + "</p>";
txt+= "<p>User agent language: "+ navigator.language + "</p>";

 Try It! 


The information from the navigator object is misleading and should not be used to detect the browser version because:

  • Navigator data can be changed by the browser user.

  • Some browsers recognize errors on the test site.

  • Browsers cannot report new operating systems that are released later than the browser.

Browser detection

Because navigator can mislead browser detection, object detection can be used to sniff different browsers.

Due to different browsers support different objects, you can use objects to detect browsers. For example, since only Opera supports the property "window.opera", you can identify Opera accordingly.

example: if (window.opera) {... some actions ...}