BOM 操作

Browser - Object - Model

可以获取页面加载之外的,浏览器的一些信息。

  • navigator

    navigator 中有 userAgent 的属性,一般简称 ua
    这是一个浏览器特性,是一个字符串,里面包含了浏览器的一些信息。
    一般用于检测浏览器属性比如:

    var ua = navigatior.userAgent
    var isChrome = ua.indexOf("Chrome")
    console.log(isChrome)  //true or false
    
  • screen

    一些关于屏幕的信息,能通过 screen 获取到
    console.log(screen.width)
    console.log(screen.height)

  • location

    可以用于获取当前的 url 以及对该 url 进行一些操作

    console.log(location.href)         // 
    console.log(location.protocaol)    // 协议 ‘http’ ‘https’
    console.log(location.host)         // 域名
    console.log(location.pathname)     // 路径
    console.log(location.search)       // 查询
    console.log(location.hash)         // 哈希
    
  • history

    控制历史记录的,一般用于浏览器前进后退
    history.back()
    history.forward()



Wait me back

你可能感兴趣的:(BOM 操作)