<JavaScript> 九. BOM其它對象(screen對象, navigator對象, location地址欄對象, history記錄對象)

來源:互聯網
上載者:User

標籤:表示   text   for   重新整理   war   onclick   pre   htm   length   

 1 <!DOCTYPE html> 2 <html> 3 <head> 4     <title></title> 5 <script type="text/javascript"> 6  7 /* 8     screen 螢幕對象 9     ------------------- 屬性 ---------------------10     width: 螢幕寬度11     height: 螢幕高度12     availWidht: 有效寬度, 不含工作列13     availHeight: 有效高度, 不含工作列14     都是唯讀屬性15 */16 var str = "<h2>螢幕的尺寸</h2>"17 str += "寬度: " + screen.width + ", 高度: " + screen.height + "<br>";18 str += "有效寬度: " + screen.availWidth + ", 有效高度: " + screen.availHeight + "<br>";19 document.write(str);20 document.write("<hr>");21 22 /*23     navigator 瀏覽器對象24     ------------------- 屬性 ---------------------25     appName: 軟體名稱26     appVersion: 核心版本27     systemLanguage: 系統語言28     userLanguage: 使用者語言29     platform: 使用者平台30 */31 var str = "<h2>瀏覽器資訊</h2>";32 str += "appName: " + navigator.appName;33 str += "<br>appVersion: " + navigator.appVersion;34 str += "<br>systemLanguage: " + navigator.systemLanguage;35 str += "<br>userLanguage: " + navigator.userLanguage;36 str += "<br>platform: " + navigator.platform;37 document.write(str);38 document.write("<hr>");39 40 /*41     location 地址欄對象42     ------------------- 屬性 ---------------------43     href: 擷取完整的地址, 可以實現JS的網頁跳轉44     host: 主機名稱45     hostname: 主機名稱46     pathname: 檔案路徑及檔案名稱47     search: 查詢字串48     protocol: 協議 http:// ftp://49     hash: 錨點名稱 #top50     reload(true): 重新整理網頁, true表示強制重新整理51 */52 // 3秒後跳轉百度53 // window.setTimeout("location.href = ‘http://www.baidu.com‘", 3000);54 55 /*56     histroy 記錄對象57     ------------------- 屬性 ---------------------58     length: 記錄個數59     go(n): 前進n頁60     go(0): 重新整理61     go(-n): 後退n頁62     forward(): 前進63     back(): 後退64 */65 </script>66 </head>67 <body>68 69 <!-- 地址欄對象 -->70 <input type="button" value="重新整理網頁" onclick="javascript:location.reload(true)">71 <hr>72 73 <!-- 記錄對象 -->74 <a href="news.html">新聞</a>75 <input type="button" value="前進" onclick="history.go(1)">76 77 </body>78 </html>

 

<JavaScript> 九. BOM其它對象(screen對象, navigator對象, location地址欄對象, history記錄對象)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.