Javascript 筆記與總結(2-5)window 對象

來源:互聯網
上載者:User

標籤:

瀏覽器 window 對象(BOM)是瀏覽器宿主對象,和 js 語言無關。

【window 對象的方法】

window.alert(message);window.confirm(message);window.prompt(message[,defaultstr]);window.close(); 關閉視窗window.print(); 列印window.setIntval(運算式,毫秒)window.clearIntval(定時器對象)window.setTimeout(運算式,毫秒)window.clearTimeout(定時器對象)

 

【window 對象的子物件】

▲navigator 瀏覽器資訊對象    △appCodeName 內部代碼    △appName 瀏覽器名稱    △appVersion 瀏覽器版本    △platform 作業系統類型    △userAgent 使用者代理程式資訊    △cookieEnabled 是否支援 cookie▲ location 地址欄對象    △host 主機    △port 連接埠    △href 地址    △pathname 路徑    △protocol 協議    △search 查詢字串    △assign(url) 頁面跳轉▲ history 記錄    △length 記錄的數目    △back();    △foeward();    △ go();▲ screen 螢幕對象    △height 高度    △width 寬度    △availHeight 可用高度                     △availWidth 可用寬度            △colorDepth 顏色▲ document HTML 文檔對象即 HTML 程式碼形成的對象,可動態改變頁面的內容

【例】navigator 對象

<script>console.log(window.navigator);</script>

 

輸出:

 

【例】location 對象

<script>console.log(window.location);</script>

輸出:

search 代表參數,例如 ?id=3

跳轉:

window.location.href = ‘*******.html‘

 

【例】document 對象(DOM 對象,window 對象的子物件)

<script>console.log(window.document);</script>

輸出:

 

Javascript 筆記與總結(2-5)window 對象

聯繫我們

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