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);