当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JS判断浏览器之Navigator对象

Javascript
javascript 汉字与拼音转换
JavaScript使用cookie
大平洋汽车网左侧菜单
使用JS操作页面表格,元素的一些技巧
分享我学习js的过程 作者aircy javascript学习教程
张孝祥JavaScript学习阶段性总结(2)--(X)HTML学习
用js来生成随机彩票号码清单
发一个数据过滤的代码,很简单,有用的着的拿去
如何在标题栏显示框架内页面的标题
js滚动条多种样式,推荐
再次更新!MSClass (Class Of Marquee Scroll通用不间断滚动JS封装类 Ver 1.6)
符合web标准的连续滚动图像的js代码
使用iframe作为日历的载体,不再被select和flash等控件挡住的日期输入框
通过脚本控制指定内容不能被选择
模拟弹出窗口效果,关闭层之前,不能选择后面的页内容
另类弹出窗口,跳过所有拦截工具
使用prototype.js进行异步操作
JS模拟多线程
动态增加/删除文件域
[分享]一个非常漂亮的进度滚动条

Javascript 中的 JS判断浏览器之Navigator对象


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 44 ::
收藏到网摘: n/a

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 全选 提示:你可先修改部分代码,再按运行]

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 全选 提示:你可先修改部分代码,再按运行]