Skip to content

一、JS Web API-BOM

BOM(Browser Object Model)

  • 如何识别浏览器的类型
  • 分解拆解url各个部分

1. navigator history screen location

  • navigator

    js
      const ua = navigator.userAgent
      const isChrome = ua.indexOf('Chrome')
      console.log(isChrome)
  • screen

    js
      console.log(screen.width)
      console.log(screen.height)
  • location

    js
      console.log(location.href) //网址
      console.log(location.protocol) //协议
      console.log(location.host) //域名
      console.log(location.search) //取网址中的参数,一般是?后面的符号
  • history

    js
      history.back() //后退
      history.forward() //前进

Released under the MIT License.