JavaScript-BOM对象
什么是BOM对象?
Browser Object Model 为浏览器对象模型,其实就是专门操作浏览器窗口的一组对象和函数。
window:代表浏览器窗口
<script>
//弹窗
window.alert(1);
//窗体内部高度
window.innerHeight;
//窗体内部宽度
window.innerWidth;
//窗体外部高度
window.outerHeight
//窗体外部宽度
window.outerWidth
</script>
Navigator:封装了浏览器信息
screen:代表屏幕
<script>
//屏幕宽度
screen.width;
//屏幕高度
screen.height;
</script>
location :代表当前页面url信息
<script>
//主机
location.host;
//当前位置
location.href;
//协议
location.protocol;
//重新加载
location.reload();
//设置地址url
location.assign('url ');
</script>
document:当前页面 (节点)
<script>
//标题
document.title;
//通过id,class...获取节点
document.getElementById();
//cookie
document.cookie;
</script>
history:代表历史记录
<script>
//后退
history.back();
//前进
history.forward();
</script>