js瀏覽器對象

來源:互聯網
上載者:User

標籤:返回   寬高   螢幕寬度   sign   index   path   單位   comm   protocol   

window

window對象不但充當全域範圍,而且表示瀏覽器視窗。

window對象有innerWidthinnerHeight屬性,可以擷取瀏覽器視窗的內部寬度和高度。內部寬高是指除去功能表列、工具列、邊框等佔位元素後,用於顯示網頁的淨寬高。

screen

screen對象表示螢幕的資訊,常用的屬性有:

  • screen.width:螢幕寬度,以像素為單位;
  • screen.height:螢幕高度,以像素為單位;
  • screen.colorDepth:返回顏色位元,如8、16、24。
location

location對象表示當前頁面的URL資訊。例如,一個完整的URL:

http://www.example.com:8080/path/index.html?a=1&b=2#TOP

可以用location.href擷取。要獲得URL各個部分的值,可以這麼寫:

location.protocol; // ‘http‘location.host; // ‘www.example.com‘location.port; // ‘8080‘location.pathname; // ‘/path/index.html‘location.search; // ‘?a=1&b=2‘location.hash; // ‘TOP‘

要載入一個新頁面,可以調用location.assign()。如果要重新載入當前頁面,調用location.reload()方法非常方便。

document

document對象表示當前頁面。由於HTML在瀏覽器中以DOM形式表示為樹形結構,document對象就是整個DOM樹的根節點。

js瀏覽器對象

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.