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