js之瀏覽器物件模型(BOM)

來源:互聯網
上載者:User

標籤:

一、BOM的階層:

window(可以訪問BOM中的所有元素,是最頂層的元素)下一層包括如下:

→document (document的屬性:forms、cookie、links/anchors、images...)                                                                    

→navigator

→location 與頁面位置相關(屬性(常用):href、target...)

→frames

→screen

→history

(畫圖更清晰)

 

window對象的使用可以分屬性和方法兩部分總結:

所有 JavaScript 全域對象、函數以及變數均自動成為 window 對象的成員。

全域變數是 window 對象的屬性。

全域函數是 window 對象的方法(例如:window.alert()、window.confirm()、window.prompt()、window.open())。

 

window對象的方法和屬性分4類:

1.建立新視窗,維護現有視窗的行為(對話方塊:window.alert()、window.confirm()、window.prompt(),建立自訂視窗:window.open());

2.在視窗中建立帶分區的文檔(表單和iframe);

3.定時器的建立和控制(setTimeout、clearTimeout);

4.用來控制瀏覽器視窗內特定元素的屬性(document、navigator、screen等)。

 

window對象和document對象的區別?

     剛不熟悉js的時候對window對象和document對象分不清。

    window對象封裝了整個瀏覽器環境,它是一個全域對象,每一個window對象代表著一個瀏覽器視窗,訪問其內部的其它對象,而且window可以省略。

區別:1、window 指表單,document指頁面。document是window的一個子物件。        2、使用者不能改變 document.location(因為這是當前顯示文檔的位置)。但是,可以改變window.location (用其它文檔取代當前文檔)window.location本身也是一個對象,而document.location不是對象

        document是window對象的一個子物件,document指頁面。

 

參考資料:

       《javascript學習指南》

         部落格: http://blog.csdn.net/qq_21577869/article/details/46895365

    

 

js之瀏覽器物件模型(BOM)

聯繫我們

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