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 ...
随机推荐
- 在centos7.4上安装mysql5.5
from: https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7
- Node js : Best way to define entity class
If you start to use a DB like mongo, you might be better off creating objects with mongoose but th ...
- Discuz!X/数据库操作方法
原DB类的改进 Discuz! X2.5新版对数据库DB层进行了功能和安全方面的加强: addslashes的处理 仅insert(),update(),delete() 方法对传入其的数组形式的参数 ...
- VMware虛擬化技術實作問答
http://www.netadmin.com.tw/article_content.aspx?sn=1202130002&ns=1203280001&jump=3 Q4:啟用VMwa ...
- C语言读取 未知长度 的矩阵
1.确定矩阵行数: 使用每次读取一行函数fgets - row = 0; while(fgets(buf, buflen, fp) != NULL) row++; - 2.确定矩阵列数: - re ...
- Linux下利用signal函数处理ctrl+c等信号
前言 linux下能够通过信号机制来实现程序的软中断,是一个很实用的编程方法. 我们平时在程序执行的时候按下ctrl-c.ctrl-z或者kill一个进程的时候事实上都等效于向这个进程发送了一个特定信 ...
- Aerospike系列:3:aerospike特点分析
1. 数据存放 数据可以放内存,也可以放SSD. 数据放内存时速度肯定会很快,但这和memcache一样,相比memcache性能并没有优势 数据放内存时可以进行持久化配置,但文档只有一个地方提了 ...
- CSS拾遗
1:CSS样式的声明 选择符{ 属性:值; 属性:值; ... } 其中,选择符有: 标签选择器:标签名{样式} 类选择器: .类名{样式} ID选择器: #ID名{样式} 另外:样式属性的书写格式 ...
- JSON语言规范与Java中两种解析工具基本使用
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6652250.html 一:JSON语言规范 一言以蔽之:“一个 :一个键值对,一个{}一个对象,一个[]一个 ...
- 转:Flash 插件面板 DragonBonesDesignPanel 的绿色安装方法
最近在cocos2d-js下捣腾Dragonbones.转一个文章,大家可以参考安装Dragonbones.关于这个Dragonbones,5月份的时候还用得好好的,cocos2d-js还能妥妥的加载 ...