Home Basics JavaScript navigator object

JavaScript navigator object

The JavaScript navigator object is used for browser detection.

It can be used to retrieve various bits of browser information such as appName, appVersion, userAgent, langauge and more

The navigator object is the window property, so it can be accessed by:

window.navigator  or navigator

Properties and Methods


Property / Method Description
activeVrDisplays Returns an array of every VRDisplay instance with its presenting property set to true
appCodeName This returns “Mozilla” even in non-Mozilla browsers.
appName Returns the full browser name.
appVersion Returns the browser version. This may not correspond to the actual version of the browser.
battery a BatteryManager object to interact with the Battery status API
buildId Returns the build number of the web browser.
connection a NetworkInformation object to interact with the Network information API
cookieEnabled Returns true if cookies are enabled; otherwise returns false.
credentials a CredentialsContainer to interact with the Credentials Management API
deviceMemory Returns the amount of device memory in gigabytes.
doNotTrack Returns the user’s preference of do-not-track .
geolocation a Geolocation object to interact with the Geolocation API.
getVRDisplays() an array of every VRDisplay instance if available.
getUserMedia() Returns the stream associated with the available media device hardware.
hardwareConcurrency Returns the number of processor cores of the device
javaEnabled Is Java enabled in the browser.
language Browser’s primary language.
languages Returns an array of all the browser’s preferred languages.
locks Returns a LockManager object to interact with the Web Locks API.
mediaCapabilities Returns a MediaCapabilities object to interact with the Media capabilities API
mediaDevices Returns the available media devices.
maxTouchPoints Returns the maximum number of supported touch points for the device’s touchscreen
mimeTypes MIME types registered with the browser.
onLine Specifies if the browser is connected to the Internet.
oscpu The operating system and/or CPU on which the browser is running.
permissions Returns the Permissions object to interact with the Permissions API.
platform Returns the system platform on which the browser is running.
plugins Installed browser’s plug-ins.
product Returns the name of the product.
productSub Extra information about the product.
registerProtocolHandler() Registers a website as a handler for a particular protocol.
requestMediaKeySystemAccess() Returns a Promise which resolves to a MediaKeySystemAccess object.
sendBeacon() Asynchronously transmits a small payload.
serviceWorker Returns the ServiceWorkerContainer used to interact with ServiceWorker object
share() Calls the current platform’s native sharing mechanism.
storage Returns the StorageManager object to interact with the Storage API.
userAgent Represents the user-agent string of the browser.
vendor  brand name of the browser.
vendorSub Returns extra information about the browser’s vendor.
vibrate() This triggers the device to vibrate if it is supported.
webdriver This returns if the browser is currently controlled by automation.

Example

 

<script>  
document.writeln("<br/>navigator.appCodeName: "+navigator.appCodeName);  
document.writeln("<br/>navigator.appName: "+navigator.appName);  
document.writeln("<br/>navigator.appVersion: "+navigator.appVersion);  
document.writeln("<br/>navigator.cookieEnabled: "+navigator.cookieEnabled);  
document.writeln("<br/>navigator.language: "+navigator.language);  
document.writeln("<br/>navigator.userAgent: "+navigator.userAgent);  
document.writeln("<br/>navigator.platform: "+navigator.platform);  
document.writeln("<br/>navigator.onLine: "+navigator.onLine);  
</script>

This displayed the following

navigator.appCodeName: Mozilla
navigator.appName: Netscape
navigator.appVersion: 5.0 (Windows)
navigator.cookieEnabled: true
navigator.language: en-GB
navigator.userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0
navigator.platform: Win32
navigator.onLine: true

You may also like