浏览器对象模型(BOM)使javascript有能力与浏览器对话
window对象,所有浏览器都支持window对象,它表示浏览器窗口,
所有javascript全局对象,函数以及变量均自动成为window对象的成员
全局变量是window对象的属性,全局函数是window对象的方法,
甚至html dom的document也是window对象的属性之一:
window.document.getElementById("header");
与此相同:
document.getElementById("header');
window尺寸,
三种方法能够确定浏览器窗口的尺寸(浏览器的视口,不包括工具栏和滚动条)
window.innerHeight -- 浏览器窗口的内部高度,
window.innerWidth-- 浏览器窗口的内部宽度.
document.documentElement.clientHeight,
document.documentElement.clientWidth
document.body.clientHeight,
document.body.clientWidth
var w=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
var h=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;
window.open() 打开新窗口
window.close() -关闭当前窗口
window.moveTo() 移动当前窗口
window.resizeTo() -- 调整当前窗口的尺寸