JavaScript BOM Navigator Object
BOM - Navigator Object :
It contains information about the client, that is, the browser on which the web page is rendered. Following properties and methods help us get this information.
Property |
Description |
Example |
appName |
Returns name of client (browser) |
navigator.appName;
//Browser's name: Netscape |
appVersion |
Returns platform (operating system) and version of client (browser) |
navigator.appVersion;
//Browser's version: 5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 |
platform |
Returns name of user's operating system |
navigator.platform;
//Browser's platform: Win 32 |
userAgent |
Returns string equivalent to HTTP user-agent request header |
navigator.userAgent;
//Browser's useragent: Mozilla/5.0 5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 |
The values shown in the output is for browser Chrome running on Windows.
Demo :
CODE/PROGRAM/EXAMPLE
document.write(
‘navigator.appName: <span class="blinking">’ +
navigator.appName +
"</span><br><br>"
);
document.write(
‘navigator.appVersion: <span class="blinking">’ +
navigator.appVersion +
"</span><br><br>"
);
document.write(
‘navigator.platform: <span class="blinking">’ +
navigator.platform +
"</span><br><br>"
);
document.write(
‘navigator.userAgent: <span class="blinking">’ +
navigator.userAgent +
"</span><br><br>"