Navigator object in Javascript
In JavaScript, object is the container of properties/variables and methods/functions. Navigator is the object which contains some methods to perform some web browser related navigation functions.
Navigator properties and methods
navigator 'online' property in JavaScript
This property checks whether the browser is online or not. If the browser is online it returns true and if the browser is offline then it returns false
var x = "browser is online: " + navigator.onLine;
document.write(x);
Output:
The code above will display :
navigator 'language' property in JavaScript
The language property returns the language version of the browser.
var lang = "Language of the current browser is : " + navigator.language;
document.write(lang);
Output:
The code above will display :
navigator 'appName' property in JavaScript
The appName property returns the name of the browser.
var name = "The current browser name is : " + navigator.appName;
document.write(name);
Output:
The code above will display :
navigator 'appVersion' property in JavaScript
The appVersion property returns the version information of the browser.
var version = "Current Browser Version Info: " + navigator.appVersion;
document.write(version);
Output:
The code above will display :
navigator 'appCodeName' property in JavaScript
The appCodeName property returns the code name of the current browser.
var codename = "Current Browser CodeName: " + navigator.appCodeName;
document.write(codename);
Output:
The code above will display :
navigator 'cookieEnabled' property in JavaScript
The cookieEnabled property returns a Boolean value that specifies whether cookies are enabled in the current browser or not.
var cookie = "current browser Cookies Enabled : " + navigator.cookieEnabled;
document.write(cookie);
Output:
The code above will display :
navigator 'platform' property in JavaScript
The platform property returns for which platform(Operating System) the current browser is compiled.
var os = "Platform: " + navigator.platform;
document.write(os);
Output:
The code above will display :
navigator 'product' property in JavaScript
The product property returns the engine (product) name of the browser.
var name = "Browser's Engine Name is : " + navigator.product;
document.write(name);
A browser engine (also known as a layout engine or rendering engine) is a core software components of every major web browser. The primary job of a browser engine is to transform HTML documents and other resources of a web page into an interactive visual representation on a user's device.
Output:
The code above will display :