1.BOM
1.Windows
1.windows对象浏览器的实例(Global对象)
2.通过var声明的所有全局变量和函数都会变成Windows对象的属性和方法,所以使用let,const来替代
3.窗口大小,innerWidth,innerHeight (页面),outreWidth,outerHeight(窗口)
3.定时器setTimeout,js是单线程的,js维护了一个任务队列,其中任务会按照添加到队列的先后顺序执行,sto的参数,只是多长时间后把这个任务添加到队列,setInterval()会每隔固定时间段,将任务加到队列中
let num=0,intervalid=null;
let max=10;
let increment1 = function () {
num++;
console.log(num);
if(num==max){
clearInterval(intervalid);
console.log('====================================');
console.log('Done');
console.log('====================================');
}
}
intervalid=setInterval(increment1, 500);
let increment = function () {
num++;
console.log(num);
if(num<max){
setTimeout(increment,500)
}else{
console.log('Done');
}
}
setTimeout(increment,500)
4.系统对话框1.alert,confrim,prompt
2.location对象
1.提供当前窗口种加载文档的信息,以及通常的导航功能,它既是windows,也是document的属性,location对象不仅保存着当前加载文档的信息,也保存着把url解析成为离散片段后能通过属性访问的信息
url:http://foouser:password@www.wst.com:80/JHBB/?q=javascript#content
location.hash | #content |
host | www.wst.com:80 |
hostname | www.wst.com |
href | http://www.wst.com:80/JHBB/?q=javascript#content |
pathname | /JHBB/ |
port | 80 |
protocol | http: |
search | ?q=javascript |
username | foouser |
password | password |
origin | http://www.wst.com |
2.
let q='?q=javascript&num=10&name=wst'
let args=new URLSearchParams(q)
console.log(args.has('name'));
console.log(args.get('name'));
args.set('page',3)
console.log(args.toString());
args.delete('page')
console.log(args.toString());
//true
wst
q=javascript&num=10&name=wst&page=3
q=javascript&num=10&name=wst
3.操作地址,location.assign()
修改url后,浏览器历史记录中就会增加相应记录,后退,可以导航到上个页面,如果不希望增加可以使用replace()
3.navigator
1.客户端识别浏览器的标准,通常用于确认浏览器的类型
2.插件检测,plugins,windows.navigator.plugins
4.screen
5.history
1.导航history.go(-1) history.back() history.forward() history.go(xxx)
2.历史状态管理