JavaScript Window Navigator 浏览器本身的信息
window.navigator 对象包含有关访问者浏览器的信息。
Window Navigator
window.navigator 对象在编写时可不使用 window 这个前缀。
Navigator Object Properties
Property | Description |
---|---|
appCodeName | Returns the code name of the browser |
appName | Returns the name of the browser |
appVersion | Returns the version information of the browser |
cookieEnabled | Determines whether cookies are enabled in the browser |
language | Returns the language of the browser |
onLine | Determines whether the browser is online |
platform | Returns for which platform the browser is compiled |
product | Returns the engine name of the browser |
userAgent | Returns the user-agent header sent by the browser to the server |
Navigator Object Methods
Method | Description |
---|---|
javaEnabled() | Specifies whether or not the browser has Java enabled |
taintEnabled() | Removed in JavaScript version 1.2. Specifies whether the browser has data tainting enabled |
实例:
<html>
<body>
<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>
</body>
</html>
警告:来自 navigator 对象的信息具有误导性,不应该被用于检测浏览器版本,这是因为:
- navigator 数据可被浏览器使用者更改
- 浏览器无法报告晚于浏览器发布的新操作系统
浏览器检测
由于 navigator 可误导浏览器检测,使用对象检测可用来嗅探不同的浏览器。
由于不同的浏览器支持不同的对象,您可以使用对象来检测浏览器。例如,由于只有 Opera 支持属性 "window.opera",您可以据此识别出 Opera。
例子:if (window.opera) {...some action...}
JavaScript Window Navigator 浏览器本身的信息的更多相关文章
- JavaScript Window Navigator
window.navigator 对象包含有关访问者浏览器的信息. Window Navigator window.navigator 对象在编写时可不使用 window 这个前缀. 实例 <d ...
- JavaScript Window History 浏览器的历史
window.history 对象在编写时可不使用 window 这个前缀. 为了保护用户隐私,对 JavaScript 访问该对象的方法做出了限制. 一些方法: history.back() - 与 ...
- JavaScript获取浏览器版本等信息
** 不同浏览器版本可能存在差异,使用时请测试自己的环境 ** 测试时各个浏览器版本 IE: 11.953.14393.0 Edge: Microsoft Edge 38.14393.0.0;Micr ...
- Javascript中获取浏览器类型和操作系统版本等客户端信息常用代码
/** * @author hechen */ var gs = { /**获得屏幕宽度**/ ScreenWidth: function () { return window.screen.widt ...
- JavaScript | window浏览器对象模型
Js Window - 获取浏览器窗口 全局变量是window对象的属性 全局函数是window对象的方法 HTML DOM的document是window对象属性之一 window.document ...
- javascript宿主对象之window.navigator
window.navigator用来反映浏览器及其功能信息的对象. // 检测浏览器版本信息 function getBrowserInfo(){ var Sys = {}; var ua = win ...
- 使用window.navigator.userAgent属性判断浏览器类型及版本
使用window.navigator.userAgent属性判断浏览器类型及版本 2011-12-11 22:03:11 window.navigator.userAgent属性包含了浏览器类型.版本 ...
- 用 JavaScript 检测浏览器在线/离线状态(JavaScript API — navigator.onLine)
如今HTML5 移动应用或 Web app 中越来越普遍的使用了离线浏览技术,所以用 JavaScript 检测浏览器在线/离线状态非常常见. 无论浏览器是否在线,navigator.onLine 属 ...
- 利用window.navigator.userAgent判断当前是否微信内置浏览器
<!DOCTYPE HTML> <html lang="en"> <head> <meta charset="utf-8&quo ...
随机推荐
- JS实现千分位
方法一:正则实现 function format (num) { ,}(?=(\d{})+$)/g; return (num + '').replace(reg, '$&,'); } 解释: ...
- python机器学习sklearn 岭回归(Ridge、RidgeCV)
1.介绍 Ridge 回归通过对系数的大小施加惩罚来解决 普通最小二乘法 的一些问题. 岭系数最小化的是带罚项的残差平方和, 其中,α≥0α≥0 是控制系数收缩量的复杂性参数: αα 的值越大,收缩量 ...
- 如何在编辑器里添加CSS或JS代码
//编辑器里代码模式下的代码 <scripttype="text/javascript"> //my code.... </script> //编辑器里可视 ...
- libsvm使用说明
http://www.hankcs.com/ml/libsvm-usage.html libsvm使用说明 码农场 > 机器学习 2016-02-18 阅读(345) 评论(0) 目录 l ...
- SharePoint CAML Query小结
CAML的结构. <View Type="HTML" Name="Summary"> <ViewBody ExpandXML="TR ...
- 企业防火墙之iptables
1.1 企业中安全优化配置原则 尽可能不给服务器配置外网ip ,可以通过代理转发或者通过防火墙映射.并发不是特别大情况有外网ip,可以开启防火墙服务. 大并发的情况,不能开iptables,影响性能, ...
- linux:C++的socket编程
基本的局域网聊天 局域网聊天TCP服务端: #include <sys/types.h> #include <sys/socket.h> #include <stdio. ...
- var, object, dynamic的区别以及使用
var, object, dynamic的区别以及使用 阅读目录: 一. 为什么是它们三个 二. 能够任意赋值的原因 三. dynamic的用法 四. 使用dynamic的注意事项 拿这三者比较的原因 ...
- 转:nginx基础概念(keepalive、pipe)
keapalive 当然,在nginx中,对于http1.0与http1.1也是支持长连接的.什么是长连接呢?我们知道,http请求是基于TCP协议之上的,那么,当客户端在发起请求前,需要先与服务端建 ...
- React (native) 相关知识
container component provider组件 react里的redux进阶玩法 react组件的生命周期 conductor / componentWillMount / render ...