SoFunction
Updated on 2025-04-06

JS judges the Navigator object of the browser

The Navigator Object
Navigation Objects
The JavaScript Navigator object contains all information about the visitor's browser. We are going to look at two properties of the Navigator object:
The JS navigation object contains all information about accessing this browser. We will look at the products of two navigation objects:

appName -  holds the name of the browser
appName - containing the name of the browser
appVersion - holds, among other things, the version of the browser
appVersion - Browser Version
Example
Give an example

[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]

The variable browser in the example above holds the name of the browser, . "Netscape" or "Microsoft Internet Explorer".
In the above example, the variable browser (browser) is assigned the name of the browser, Netscape or IE (or others)

The appVersion property in the example above returns a string that contains much more information than just the version number, but for now we are only interested in the version number. To pull the version number out of the string we are using a function called parseFloat(), which pulls the first thing that looks like a decimal number out of a string and returns it.
The appVersion property in the above example returns a string of information characters containing more information than the version number, but now we only have the version number. To propose a version number from a string, we use a function called parseFloat() to return the number.

IMPORTANT! The version number is WRONG in IE 5.0 or later! Microsoft start the appVersion string with the numbers 4.0. in IE 5.0 and IE 6.0!!! Why did they do that??? However, JavaScript is the same in IE6, IE5 and IE4, so for most scripts it is ok.
(Ask for JS to return IE version number)

Example
Give an example
The script below displays a different alert, depending on the visitor's browser:
Depending on the visitor's browser, the following script (different browsers) will display different warnings:


[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]