Determining browser Navigator objects by JS

Source: Internet
Author: User

The Navigator Object
Navigation object
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. Let's take a look at the products of two navigation objects:

AppName-holds the name of the browser
AppName-includes the browser name
AppVersion-holds, among other things, the version of the browser
AppVersion-browser version
Example
Example
<Html> <body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
The variable browser in the example abve holds the name of the browser, I. e. "Netscape" or "Microsoft Internet Explorer ".
In the preceding example, the variable brower (browser) is assigned the browser name, Web View, or IE (or other)

The appVersion property in the example abve 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 attribute in the above example returns a string containing more information characters than the version number, but now we only need the version number. To extract the version number from the string, we use a function called parseFloat () to return the number.

IMPORTANT! The version number is WRONG in Internet Explorer 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.
(About the IE version number returned by JS)

Example
Example
The script below displays a different alert, depending on the visitor's browser:
Depending on the visitor's browser, the following scripts will display different Alerts:

<Html> <pead> </pead> <body onload = "detectBrowser ()"> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.