navigator对象介绍

<html>
<head>

<title>
测试navigator对象
</title>
<body>
 <script>
 document.write("navigator.appName="+navigator.appName);
 document.write("<br>");
 document.write("parseFloat(navigator.appVersion)="+parseFloat(navigator.appVersion));
 document.write("<br>appVersion属性返回一串包含比版本号更多的信息字符,但现在我们只要版本号。要从字符串中提出版本号我们使用一个叫parseFloat()的函数来返回数字。");
 document.write("navigator.appVersion="+parseFloat(navigator.appVersion));
 document.write("<br>");
 document.write("navigator 对象的属性:"+"</br>");
document.write("appcodename:"+navigator.appCodeName+"<br>")
document.write("appname::"+navigator.appName+"<br>")
document.write("appversion:"+navigator.appVersion+"<br>")
document.write("platform:"+navigator.platform+"<br>")
document.write("userAgent:"+navigator.userAgent+"<br>")
document.write("navigator对象的方法"+"<br>")
document.write("1.javaEnabled():"+navigator.javaEnabled()+"</br>")
if(navigator.appName.indexOf("Microsoft")!=-1){
document.write("用户浏览器是微软的IE浏览器"+"<br>")}
else if(navigator.appName.indexOf("Netscape")!=-1){
document.write("用户浏览器是netscape的netscape浏览器"+"<br>")}
if(navigator.appVersion.indexOf("4.0")!=-1){
document.write("this browser is not 4.0 compliant.<br>")
}
else{
document.write("you are using a version 4.0compatible browser")}
document.write("location对象的属性"+"<br>")
document.write("1.hash"+location.hash+"<br>")
document.write("2.hostname"+location.hostname+"<br>")
document.write("3.host"+location.host+"<br>")
document.write("4.href:"+location.href+"<br>")
document.write("5.port:"+location.port+"<br>")
document.write("6.search"+location.search+"<br>")
 </script>
</body>
</html>

 

结果:

navigator.appName=Microsoft Internet Explorer
parseFloat(navigator.appVersion)=4
appVersion属性返回一串包含比版本号更多的信息字符,但现在我们只要版本号。要从字符串中提出版本号我们使用一个叫parseFloat()的函数来返回数字。navigator.appVersion=4
navigator 对象的属性:
appcodename:Mozilla
appname::Microsoft Internet Explorer
appversion:4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
platform:Win32
userAgent:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
navigator对象的方法
1.javaEnabled():true
用户浏览器是微软的IE浏览器
this browser is not 4.0 compliant.
location对象的属性
1.hash
2.hostname
3.host
4.href:file:///C:/Documents%20and%20Settings/Administrator/桌面/openHTML.html
5.port:
6.search

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值