About the Navigator property in JavaScript

Source: Internet
Author: User

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

The Window.navigator object does not use the prefix of window when writing. instance

<div id= "Example" ></div>

<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: The information from the Navigator object is misleading and should not be used to detect browser versions because: Navigator data can be changed by the browser Consumer browser can not report later than the browser published new operating system 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 attribute "Window.opera", 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.