BOM
BOM(Browser Object Model):浏览器对象模型,提供了一套操作浏览器功能的工具。
window.onload
window.onload事件会在窗体加载完成后执行,通常我们称之为入口函数。
| 1 2 3 4
 | window.onload = function(){ 	 	 }
 | 
window.open 打开窗口
| 1 2 3 4 5 6 7 8 9
 | 	 	 var newWin = window.open("http://www.baidu.com","_blank", "width=300,height=300");
 | 
window.close 关闭窗口
| 1 2
 | newWin.close(); window.close();
 | 
定时器
延时定时器
设置延时定时器
| 1 2 3 4 5 6 7 8
 | var timer = setTimeOut(function(){ 	 }, 1000);
 | 
清除延时定时器
间歇定时器
设置间歇定时器
| 1 2 3 4 5 6 7 8
 | var timer = setInterval(function(){ 	 }, 1000);
 | 
清除间歇定时器
| 1 2 3 4
 | clearInterval(timer);
 | 
location对象
location对象也是window的一个属性,location其实对应的就是浏览器中的地址栏。
常用属性和方法
location.href:控制地址栏中的地址
location.reload():让页面重新加载
| 1 2
 | location.reload(true); location.reload(false);
 | 
location的其他属性
| 1 2 3 4 5 6 7
 | console.log(window.location.hash); console.log(window.location.host); console.log(window.location.hostname); console.log(window.location.pathname); console.log(window.location.port); console.log(window.location.protocol); console.log(window.location.search);
 | 
【案例:定时跳转.html】
其他对象
window.navigator的一些属性可以获取客户端的一些信息
history对象表示页面的历史
| 1 2 3 4 5 6
 | history.back(); history.go(-1); history.forward(); history.go(1);
 | 
screen对象
| 1 2 3 4
 | console.log(screen.width); console.log(screen.height); console.log(screen.availWidth); console.log(screen.availHeight);
 |