JavaScript中BOM以及DOM的區別:
DOM w3c 讓js有能力去操做HTML和XML 間接的操做樣式
BOM 專門操做瀏覽器的API 兼容性
BOM的六個子對象
history:瀏覽器的歷史記錄
location:窗口的url 地址欄的信息
navigator: 瀏覽器的配置信息
document:DOM
screen:顯示設備的信息
event: 事件對象javascript
history:html
history.go(n) 後退 前進 刷新
前進:history.go(1)
後退:history.go(-1/-2)
刷新:history.go(0)java
eg:瀏覽器
<body>
<h1>1_history</h1>
<div>
<a href="1_history.html">1</a>
<a href="2_history.html">2</a>
<a href="3_history.html">3</a>
</div>
<div>
<a href="javascript:history.go(1)">前進一次</a>
<a href="javascript:history.go(2)">前進二次</a>
</div></body>url
<body>
<h1>2_history</h1>
<div>
<a href="1_history.html">1</a>
<a href="2_history.html">2</a>
<a href="3_history.html">3</a>
</div>
<div>
<a href="javascript:history.go(-1)">後退一次</a>
<a href="javascript:history.go(1)">前進一次</a>
</div>
</body>htm
<body>
<h1>3_history</h1>
<div>
<a href="1_history.html">1</a>
<a href="2_history.html">2</a>
<a href="3_history.html">3</a>
</div>
<div>
<a href="javascript:history.go(-2)">後退二次</a>
<a href="javascript:history.go(-1)">後退一次</a>
</div>
</body>對象
這三個頁面能夠切換,且點擊前進後退按鈕可訪問以前頁面blog
location對象:包含有關當前URL的信息事件
對象屬性:ip
hash 設置或返回從#開始的URL
host 設置或返回主機名和端口號
href 設置或返回URL
pathname 設置或返回URL路徑
search 設置或返回從?開始的URL
對象方法:
assign() 加載新的文檔
reload() 從新加載
repplace() 用心文檔替換當前文檔