瀏覽器物件模型(Browser Object Model)

來源:互聯網
上載者:User

document frames history location navigator screen

  document對象的屬性:

  anchors forms images links location

  window對象

  觀察BOM的體繫結構,所有的對象都源自window對象,它表示整個瀏覽器視窗。

  Frame實際是個array,如果視窗分禎的話,每個frame相當一個單獨的window 對象,如window.frames[0](注意,top對象的使用,top永遠指向最外層的禎,top.frames[0], 因為當你的代碼被包括在某個frame中是,這時候window指向的是當前禎,這也許不是你的原意,所以盡量使用top來避免錯誤)

  parent ,self,top,window的關係:

  parent:如果當前視窗為frame,指向包含該frame的視窗的frame (frame)

  self :指向當前的window對象,與window同意。 (window對象)

  top :如果當前視窗為frame,指向包含該frame的top-level的window對象

  window :指向當前的window對象,與self同意。

  window的有用屬性/對象與方法

  大小與移動:

  moveBy,moveTo,resizeBy,resizeTo;

  開啟popup視窗:

  open;

  系統提示窗:

  alert(),confirm(),prompt;

  狀態列:

  Status,defaultStatus;

  時間間隔:

  setTimeout(),setInterval;

  曆史紀錄:

  history.go(-1)後退

  document對象

  唯一BOM和DOM都有的對象。從BOM的角度看,側重於從集合的角度看問題,把頁面劃分為不同的部分,以及頁面本身的一些屬性,如背景色,標題名稱等,由於BOM的實現是基於瀏覽器的,所以不同瀏覽器的屬性和方法有不一致之處,這造成很多麻煩。注意一些一致的,常用的屬性和方法,BOM把頁面分為如下幾部分:

  anchors : Collection of all anchors in the page(represented by )

  applets : Collection of all applets in the page

  forms : Collection od all embeded objects in the page(represented by the tag)

  images : Collection of all forms in the page

  links : Collection of all links in the page (represented by )

  location 對象

  指瀏覽器視窗中輸入的URL,它有很多屬性,即把URL拆為了很多部分,分別表示之,如href,host,port,pathname等

  Navigator對象

  更加針對瀏覽器,舉一些IMOS都有的例子如appCodeName,appName, userAgent等

  Screen對象

  這個Screen指的是客戶電腦的螢幕,如我的機器的Screen.Heigh和Width為768X1024,例如可以用這個屬性將瀏覽器置為全屏:

  window.moveTo(0, 0);

  window.resizeTo(screen.availWidth, screen.availHeight);

聯繫我們

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