生活随笔
收集整理的這篇文章主要介紹了
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
總結
以上是生活随笔為你收集整理的navigator对象介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。