js基础总结04 --bom对象

1、Bom

定义:浏览器对象模型,包含一系列与浏览器窗口交互的对象,如:Window,Location,History,Document,Screen

2、Window对象

定义:窗口对象,所有js中的全局变量和全局函数都是它的属性。上述的location,history,document,screen都是Window这个对象的属性,还包含,alert等弹窗类方法,setTimeout,setInterval等计时器方法

3、document对象

定义:操作文档的对象

4、location对象

定义:获取当前页面的url及相关信息

location:
  • location.href = 'url地址'
  • location.hostname = 主机名
  • location.pathname = 当前页面路劲名
  • location.protocol = web协议类型
  • location.port = 端口号

5、history对象

定义:浏览器的浏览历史

  1. history.back():回退
  2. history.forward():前进
  3. history.go(number): -1:上一页 1:下一页

6、screen对象

定义:包含用户屏幕的信息

  1. screen.width or screen.height:以像素点的形式返回用户屏幕的宽度和高度
  2. screen.availWidth or screen.availHeight:以像素点的形式返回用户屏幕的可用宽度和可用高度(减去工具栏及窗口工具等)
原文地址:https://www.cnblogs.com/Zxq-zn/p/11980876.html