JavaScript navigator object is a property of the window object and it has information about the browser. You can use it for browser detection or get browser information such as appName, appCodeName, userAgent, etc.
The navigator object can be accessed by:
window.navigator
//OR
navigator
Navigator Object Properties
Here are the properties of the navigator object that returns information from the browser.
Property | Description |
---|---|
appCodeName | Returns browser code name |
appName | Returns browser name |
appVersion | Returns browser version |
cookieEnabled | Returns true if browser cookies are enabled |
geolocation | Returns a geolocation object for the user’s location |
language | Returns browser language |
onLine | Returns true if the browser is online |
platform | Returns browser platform |
product | Returns browser engine name |
userAgent | Returns browser user-agent header |
Navigator Object Methods
Here are the methods of navigator objects.
Method | Description |
---|---|
javaEnabled() | Returns true if the browser has Java enabled |
taintEnabled() | Removed in JavaScript version 1.2 (1999). |
Navigator object in JavaScript
Simple example code.
<!DOCTYPE html>
<html>
<head>
<body>
<script>
console.log("appCodeName: ", navigator.appCodeName);
console.log("appName: ", navigator.appName);
console.log("appVersion: ", navigator.appVersion);
console.log("cookieEnabled: ", navigator.cookieEnabled);
console.log("language: ", navigator.language);
console.log("userAgent: ", navigator.userAgent);
console.log("platform: ", navigator.platform);
console.log("onLine: ", navigator.onLine);
</script>
</body>
</html>
Output:

Do comment if you have any doubts or suggestions on this JS object topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version