BOM小结

BOM模型
window对象
1.moveBy(dx,dy)--相对当前位置水平和垂直移动dx,dy个像素,可以负数;
2.moveTo(x,y)--移动窗口,以左上角位于屏幕的(x,y)处,可以负数;
3.resizeBy(dw,dh)--将窗口调节成宽度,高度于dw,dh的大小,可以负数;
4.resizeTo(w,h)--将窗口调节成宽度,高度于dw,dh的大小,不能负数;
例如:
window.moveBy(10,20);
window.moveTo(150,300);
Window.resizeBy(150,0);
Window.resizeTo(0,0);

5.window.close();关闭窗口
6.alert(document.body.offsetwidth/offsetheight)针对客户区的宽高
7.alert(window.screen x/y);
8.alert(window.inner width/height);
9.打开窗口 window.open("URL")

时间间隔和暂停
    1. setTimeout() 延迟 clearTimeout 清除延迟;执行一次

      var str = (123);
      var t = window.setTimeout("alert(str)",2000);
      window.clearTimeout(t);
    2. setInterval/clearIterval 可多次执行延迟

  history历史
    1. windou.history.forward/back 前进或后退历史页面
      btn1.onclick = function() {
        window.history.forward();
      };
      btn2.onclick = function() {
        window.history.back();
      }; 
  2. window.history.go(+/-n) 当n>0,前进到第n个页面;当n<0,后退到第n个页面
  3. window.history.length() 查看历史页面个数

document对象

  1. document.lastModified 查看最后修改时间
   document.referrer 查看后退一个页面的url
   document.title 查看标题
   document.URL 查看当前页面的url
  2. anchors 锚点合集
    document.anchors.length
   forms 表单合集
   images 图片合集
   links 超链接合集
  3. document.write 向文档写入数据
   document.writeln 向文档写入数据,并已空格隔开
    document.write(123);
    document.write(123);
    document.writeln(123);
    document.writeln(123);
    document.writeln(123);

location 对象

  1.href();assign();replace() 都可以用来跳转网页,但replace()方法不会产生历史信息

  2.reload() 重新载入当前页面;值为ture时,从服务器刷新,上传数据;值为false时,本地刷 新,不上传数据


navigator 对象:关于浏览器本身的信息

  1.appCodeName 浏览器代码名的字符串表示

  2.appVersion 浏览器版本信息的字符串表示

screen 对象

  1.availHeight/Width 窗口可使用的屏幕高度/宽度

  2.height/width 屏幕的高度/宽度

  3.全屏设置(IE)
    window.moveTo(0,0);
    window.resizeTo(screen.availWidth,screen.availHeight);

原文地址:https://www.cnblogs.com/fannylovo/p/4649959.html