Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Navigator object


May 06, 2021 JavaScript with HTML DOM Reference book


Table of contents


Navigator object


Navigator object

The Navigator object contains information about the browser.

Navigator object Note: There are no public standards applied to navigator objects, but all browsers support them.


Navigator object properties

Property Description
appCodeName Returns the browser's code name
appName Returns the name of the browser
appVersion Returns the browser's platform and version information
cookieEnabled Returns the Boolean value that indicates whether cookies are enabled in the browser
platform Returns to the operating system platform on which the browser is running
userAgent Returns the value of the user-agent header of the server sent by the client

Navigator object method


Method Describe
javaEnabled() Specify whether Java is enabled in the browser
taintEnabled() Specify whether the browser enables data tainting


Third, the example



<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>W3cschool</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>

Results:

Browser code: Mozilla

Browser name: Netscape

Browser version: 5.0 (Windows NT 10.0; W in64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36

Enable cookies: true

Hardware platform: Win32

User Agent: Mozilla/5.0 (Windows NT 10.0; W in64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36

User proxy language: undefined