BOM瀏覽器物件模型

2021-07-16 17:34:03 字數 1567 閱讀 9640

bom能做什麼:操作瀏覽器視窗、提供導航物件、提供定位物件、提供跟螢幕相關物件、提供對

cookie

的支援

window物件

開啟瀏覽器後麻黃素那個建立window物件,代表整個視窗

作用:操作視窗

moveby(dx,dy):移動指定的距離

moveto(x,y):移動到指定位置

resizeby(dx,dy):修改視窗的寬高

resizeto(x,y):修改視窗的寬高指定寬高

open(url)  彈出新視窗

close()   關閉視窗

top.opener 獲取父視窗

系統對話方塊:

樣式不可更改,是模式視窗

window.alert(「字串」);

window.confirm(「選擇是或否」)    返回

boolean

window.prompt(「提示資訊」,」預設值」)  返回

string

history物件

訪問歷史頁面

window.history.go(-1) 引數是返回的頁面數,正數為前進

window.history.back()  後退

window.history.forward()  前進

window.history.length  返回歷史頁面的個數

document物件

代表視窗的空白區域,是window的屬性  

dom bom

都定義了

document。

lastmodify 頁面的最後修改日期

referrer  瀏覽歷史中的前乙個

url

title 標題欄

url  當前頁面的

url

write(「」);

writeln(「」); 使用這裡上面兩個方法時,要注意整個頁面的元素會重新設定,所以不要輕易使用

getelementbyid  得到元件物件

location物件

載入視窗的url

解析url

host: url 中的主機名稱

pathname:

url中主機名後的部分

prot :埠

protocol: 協議

search:

url中問號後面的部分

跳轉到新頁面

location.href = 「」;

location.assign(「」);

location.replace(「」)  沒有歷史資訊

重新整理頁面location.reload(boolean)

true 伺服器重新整理

false 本地重新整理

瀏覽器物件模型 BOM

bom的核心物件是window物件,其他物件都是window物件的子物件 一 瀏覽器物件模型 二 window物件 屬性 1.位置型別 瀏覽器距離螢幕的距離 ie chrome alert window.screenleft alert window.screentop ff chrome aler...

BOM 瀏覽器物件模型

延時器 var timerid settimeout cleartimeout timerid 定時器 var timerid setinterval clearinterval timerid 延時器延時一段時間執行一次 定時器 間隔一段時間不停的執行,想要停止,手動呼叫clearinterval...

BOM 瀏覽器物件模型

console.log window.name 是空 特殊地方在於js是動態類的語言,正常結果乙個是undefined console.log window.type undefined console.log top 輸出得是window物件 console.log window 和上面一樣,是等...