js中的bom學習

bom簡單來講就是相對於瀏覽器的各種對象模型。
js中的bom對象包括window、document、location、navigator、screen和history

簡單使用

1、window相關
  • window.innerHeight 獲取瀏覽器當前高度
  • window.innerWidth 獲取瀏覽器當前寬度
  • window.open(url,name,feature); 打開新窗口
  • window.close(); 關閉當前窗口
  • confirm() 確認框 返回boolean
  • alert() 警示框
  • prompt(msg,輸入內容) 提示框 返回輸入內容
2、navigator相關
  • navigator.userAgent 獲取瀏覽器的用戶代理
  • navigator.appVersion 獲取瀏覽器版本
  • navigator.platform 獲取平臺信息
3、screen相關
  • screen.height 獲取屏幕高度 (非當前)
  • screen.width 獲取屏幕寬度(非當前)
4、location相關
  • location.url 獲取url地址
  • location.reload() 重新加載頁面
5、history相關
  • history.back() 加載當前頁面的前一個頁面
  • history.forward() 加載當前頁面的後一個頁面
  • history.go(參數填-1爲上一個頁面 參數填1爲後一個頁面) 加載當前頁面的前一個頁面
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章