JS判断浏览器之Navigator对象
更新时间:2007年01月28日 00:00:00 作者:
The Navigator Object
导航对象
The JavaScript Navigator object contains all information about the visitor's browser. We are going to look at two properties of the Navigator object:
JS导航对象包含所有有关访问这者浏览器的信息。我们将看看两个导航对象的产物:
appName - holds the name of the browser
appName - 含浏览器的名称
appVersion - holds, among other things, the version of the browser
appVersion - 浏览器版本
Example
举例
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
The variable browser in the example above holds the name of the browser, i.e. "Netscape" or "Microsoft Internet Explorer".
上面例子中变量brower(浏览器)被赋加了浏览器的名称,网景或是IE(或其他)
The appVersion property in the example above returns a string that contains much more information than just the version number, but for now we are only interested in the version number. To pull the version number out of the string we are using a function called parseFloat(), which pulls the first thing that looks like a decimal number out of a string and returns it.
上面例子中的appVersion属性返回一串包含比版本号更多的信息字符,但现在我们只要版本号。要从字符串中提出版本号我们使用一个叫parseFloat()的函数来返回数字。
IMPORTANT! The version number is WRONG in IE 5.0 or later! Microsoft start the appVersion string with the numbers 4.0. in IE 5.0 and IE 6.0!!! Why did they do that??? However, JavaScript is the same in IE6, IE5 and IE4, so for most scripts it is ok.
(有关JS返回IE版本号的问题)
Example
举例
The script below displays a different alert, depending on the visitor's browser:
根据访问者的浏览器,(不同的浏览器)下面的脚本将显示不同的警示:
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
导航对象
The JavaScript Navigator object contains all information about the visitor's browser. We are going to look at two properties of the Navigator object:
JS导航对象包含所有有关访问这者浏览器的信息。我们将看看两个导航对象的产物:
appName - holds the name of the browser
appName - 含浏览器的名称
appVersion - holds, among other things, the version of the browser
appVersion - 浏览器版本
Example
举例
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
The variable browser in the example above holds the name of the browser, i.e. "Netscape" or "Microsoft Internet Explorer".
上面例子中变量brower(浏览器)被赋加了浏览器的名称,网景或是IE(或其他)
The appVersion property in the example above returns a string that contains much more information than just the version number, but for now we are only interested in the version number. To pull the version number out of the string we are using a function called parseFloat(), which pulls the first thing that looks like a decimal number out of a string and returns it.
上面例子中的appVersion属性返回一串包含比版本号更多的信息字符,但现在我们只要版本号。要从字符串中提出版本号我们使用一个叫parseFloat()的函数来返回数字。
IMPORTANT! The version number is WRONG in IE 5.0 or later! Microsoft start the appVersion string with the numbers 4.0. in IE 5.0 and IE 6.0!!! Why did they do that??? However, JavaScript is the same in IE6, IE5 and IE4, so for most scripts it is ok.
(有关JS返回IE版本号的问题)
Example
举例
The script below displays a different alert, depending on the visitor's browser:
根据访问者的浏览器,(不同的浏览器)下面的脚本将显示不同的警示:
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
您可能感兴趣的文章:
- Javascript判断对象是否相等实现代码
- js中判断Object、Array、Function等引用类型对象是否相等
- js中判断对象是否为空的三种实现方法
- JS判断对象是否存在的10种方法总结
- JavaScript 判断判断某个对象是Object还是一个Array
- javascript检测对象中是否存在某个属性判断方法小结
- Javascript中判断变量是数组还是对象(array还是object)
- JS/Jquery判断对象为空的方法
- 简单方法判断JavaScript对象为null或者属性为空
- js判断对象是否是某一类型
- JavaScript中判断对象类型的几种方法总结
- js实现数组去重、判断数组以及对象中的内容是否相同
- JS判断两个对象内容是否相等的方法示例
相关文章
nodejs的require模块(文件模块/核心模块)及路径介绍
在nodejs中,模块大概可以分为核心模块和文件模块,核心模块是被编译成二进制代码,引用的时候只需require表示符即可,文件模块,则是指js文件、json文件或者是.node文件2013-01-01JavaScript中window、doucment、body的解释
JavaScript中window、doucment、body是什么意思呢,下面为大家做个介绍,不知道的朋友可以参考下2013-08-08Web Inspector:关于在 Sublime Text 中调试Js的介绍
本篇文章小编将为大家介绍,Web Inspector:关于在 Sublime Text 中调试Js的介绍。需要的朋友可以参考一下2013-04-04
最新评论