ECMAScript各个版本都能兼容,只不过低版本不兼容ES6以上
BOM和DOM都是树形结构
BOM的根是window,DOM的根是document
BOM中包含:document(文档)、location(本地信息)、history(历史)、screen(屏幕)、navigator(浏览器信息)
window.open();window.close(); 用于弹窗,现在基本被屏蔽了。
window.innerWidth,window.innerHeight 浏览器的宽高,宽度包含滚动条,高度是文档的高度(显示的高度)。
window.outerWidth,window.outerHeight 浏览器的宽高,宽度包含滚动条,如果是非全屏,宽度包含阴影部分,高度始终为浏览器高度。
window.screenLeft,window.screenRight 浏览器距离屏幕左上角的距离,不能设置,只能获取。等同于(screenX,screenY)
window.location.reload()重新刷新页面
location.href="http://www.163.com";//href获取当前页面地址,也可以设置当前页面地址,达到跳转页面,产生历史纪录
location.assign("http://www.163.com");//只能跳转页面,能产生历史纪录
location.replace("http://www.163.com");//替换当前页面,跳转页面,不能产生历史记录
console.log(location.hash);//获取锚点名 #和后面内容
console.log(location.search);//?和后面的内容
console.log(location.hostname);
console.log(location.port);
console.log(location.pathname);//当前地址除了域名和端口号以外的路径
console.log(location.protocol);//协议
history.go(0); //刷新页面
history.go(1); //想前一个
history.go(-1); //向后一个
history.pushState(state,title,url); //不刷新浏览器改变url
screen 屏幕
console.log(screen.availWidth,screen.availHeight);//去除了任务栏的宽高
console.log(screen.width,screen.height);//全屏幕宽高
console.log(navigator.userAgent);//获取浏览器信息
console.log(navigator.platform);//区分操作系统