JavaScript Window Navigator,

Source: Internet
Author: User

JavaScript Window Navigator,
The window. navigator object contains information about the visitor's browser.

Window Navigator

Window. navigatorObjects can be written without the window prefix.

Instance

<P id = "example"> </p>

<Script>

Txt = "<p> Browser CodeName:" + navigator. appCodeName + "</p> ";
Txt + = "<p> Browser Name:" + navigator. appName + "</p> ";
Txt + = "<p> Browser Version:" + navigator. appVersion + "</p> ";
Txt + = "<p> Cookies Enabled:" + navigator. cookieEnabled + "</p> ";
Txt + = "<p> Platform:" + navigator. platform + "</p> ";
Txt + = "<p> User-agent header:" + navigator. userAgent + "</p> ";
Txt + = "<p> User-agent language:" + navigator. systemLanguage + "</p> ";

Document. getElementById ("example"). innerHTML = txt;

</Script>


Warning !!!

Information from the navigator object is misleading and should not be used to detect the browser version because:

  • Navigator data can be changed by browser users
  • Some browsers will identify errors on the test site
  • The browser cannot report a new OS released later than the browser
Browser Detection

Because navigator can mislead browser detection, object detection can be used to sniff different browsers.

Because different browsers support different objects, you can use objects to detect browsers. For example, because only Opera supports the "window. opera" attribute, you can identify Opera accordingly.

Example: if (window. opera) {... some action ...}

Related Article

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.