JavaScript Wind...LOGIN

JavaScript Window Navigator

Navigator Object

The JavaScript Navigator object contains relevant information about the browser.

Tip: Although there is no clear relevant standard for the Navigator object, all browsers support this object.

window.navigator object can be written without using the window prefix.

<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 Browser user changes

Some browsers will recognize errors for test sites

The browser cannot report new operating systems released later than the browser

Navigator object Methods

The Navigator object has the following two methods:

navigator.javaEnabled(): detects whether the browser has enabled java support and returns a Boolean value, true indicating support.

navigator.taintEnabled(): Detects whether the browser enables data tainting (data tainting), returns a Boolean value, true means enabled.


Next Section
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <div id="example"></div> <script> txt = "<p>浏览器代号: " + navigator.appCodeName + "</p>"; txt+= "<p>浏览器名称: " + navigator.appName + "</p>"; txt+= "<p>浏览器版本: " + navigator.appVersion + "</p>"; txt+= "<p>启用Cookies: " + navigator.cookieEnabled + "</p>"; txt+= "<p>硬件平台: " + navigator.platform + "</p>"; txt+= "<p>用户代理: " + navigator.userAgent + "</p>"; txt+= "<p>用户代理语言: " + navigator.systemLanguage + "</p>"; document.getElementById("example").innerHTML=txt; </script> </body> </html>
submitReset Code
ChapterCourseware