Window navigator.platform 属性
实例
获取浏览器版本:
<!DOCTYPE html>
<html>
<body>
<h2>platform 属性</h2>
<p id="demo">
<script>
let platform = navigator.platform;
document.getElementById("demo").innerHTML = "Platform: " + platform;
</script>
</body>
</html>
定义与用法
platform
属性返回为哪个平台编译浏览器。
platform
属性是只读的。
语法
navigator.platform
返回值
类型 | 描述 |
A string | 浏览器平台。 比如:
|
更多实例
显示所有 navigator 属性:
<!DOCTYPE html>
<html>
<body>
<h2>所有 navigator 属性</h2>
<div id="demo"></div>
<script>
let text = "<p>Browser CodeName: " + navigator.appCodeName + "</p>" +
"<p>Browser Name: " + navigator.appName + "</p>" +
"<p>Browser Version: " + navigator.appVersion + "</p>" +
"<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>" +
"<p>Browser Language: " + navigator.language + "</p>" +
"<p>Browser Online: " + navigator.onLine + "</p>" +
"<p>Platform: " + navigator.platform + "</p>" +
"<p>User-agent header: " + navigator.userAgent + "</p>";
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
浏览器支持
navigator.platform
所有浏览器都支持:
属性 | |||||
---|---|---|---|---|---|
navigator.platform | Yes | Yes | Yes | Yes | Yes |