BOM: browser object model 浏览器对象模型
BOM 用于独立的内容和浏览器窗口的交互
BOM 能够提供父窗口和子窗口的通信
window 对象
BOM 有对象 对象里面就有属性和方法
一、 window对象
属性:
onload 先去加载页面在加载js
parent 父窗口 子窗口 通过parent属性获取父窗口属性和方法
方法:
alert() 警告框
confirm() 确定框
prompt() 对话框
open() 打开新窗口
close() 关闭新窗口
print() 呼叫打印预览
二、 history 对象(重点内容)
window.history.go(1) 前进
window.history.go(-1) 后退
window.history.back() 后退
window.history.forward() 前进
三、 location重点
document.write(‘获取完成url路径:‘+window.location.href+‘<br/>‘);
document.write(‘获取路径:‘+window.location.pathname+‘<br/>‘);
document.write(‘获取协议:‘+window.location.protocol+‘<br/>‘);
document.write(‘获取主机名:‘+window.location.hostname+‘<br/>‘);
//跳转页面方法
location=要跳转的路径
//重新刷新页面的方法
location.reload();
四、 navigator 对象
document.write(‘浏览器代码名字:‘+navigator.appCodeName+‘<br/>‘);
document.write(‘浏览器名称:‘+navigator.appName+‘<br/>‘);
document.write(‘浏览器版本:‘+navigator.appVersion+‘<br/>‘);
document.write(‘浏览器编译平台:‘+navigator.platform+‘<br/>‘);
document.write(‘浏览器语言:‘+navigator.language+‘<br/>‘);
document.write(‘浏览器用户的表头信息:‘+navigator.userAgent+‘<br/>‘);
五、 screen() 对象
document.write(‘屏幕的宽度:‘+window.screen.width+‘<br/>‘);
document.write(‘屏幕的高度:‘+window.screen.height+‘<br/>‘);
document.write(‘文档可用高度:‘+window.innerHeight+‘<br/>‘);
document.write(‘文档可用宽度:‘+window.innerWidth+‘<br/>‘);
原文:https://www.cnblogs.com/zhony/p/10458550.html