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需再刷新一下页面才能执行]
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“JS判断浏览器之Navigator对象”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。