BOM操做(Browser Object Model:瀏覽器對象模型)

  1. JS基礎知識,規定語法(ECMA 262 標準)
  2. JS Web API,網頁操做的API(W3C標準)
JS Web API:
  • DOM
  • BOM
  • 事件綁定
  • ajax
  • 存儲

BOM知識點

  • navigator(瀏覽器的信息)
  • screen(屏幕的信息)
  • location(url的信息)
  • history(前進、後退信息)
//navigator
const ua = navigator.userAgent //獲取瀏覽器的信息
const isChrome = ua.indexOf('Chrome')

//screen
console.log(screen.width)
console.log(screen.height)

//location
console.log(location.href)
console.log(location.protocol)//"http:" "https:"
console.log(location.pathname)
console.log(location.search)
console.log(location.hash)

//history
history.back()
history.forward()

image.png

相關文章
相關標籤/搜索