javascript BOM

来源:互联网 发布:2017天猫实时数据 编辑:程序博客网 时间:2024/05/18 15:52

open 方法

  • open(url,mode,parameter)
    • mode: _blank:在新窗口显示目标网页
      _self:在当前窗口显示目标网页
      _top:框架网页中在上部窗口中显示目标网页
    • parameter
      参数表

window.navigator.userAgent

  • userAgent 属性是一个只读的字符串,声明了浏览器用于 HTTP 请求的用户代理头的值。
  • 验证浏览器可用
ifwindow.navigator.userAgent.indexOf('Chrome')){ //dosomething...}

window.location

  • window.location.href(origin)

    • ”https://www.baidu.com/”
  • window.location.search

    • “?wd=javascript”
  • window.location.hash

    • ”#article”
  • window.location.pathname

    • ”/s”

可视区域大小

  • document.documentElement.clientHeight

获取滚动条位置

IE:
document.documentElement.scrollTop

chrome :
document.body.scrollTop

兼容性写法
if(document.body.scrollTop||document.document.documentElement.scrollTop){//dosomething...}

获取内容高度

  • document.body.scrollHeight

获取文档高度

  • document.documentElement.offsetHeight(ie 默认为可视区域大小)
  • document.body.offsetHeight (都兼容)

方法

  • onscroll 以时间为基准 拉的越慢触发越多
  • onresize 事件会在窗口或框架被调整大小时发生
0 0