BOM(innerWidth、outerWidth)

 

 

 

//IE浏览器支持
alert(document.documentElement.clientWidth);
alert(document.documentElement.clientHeight);

 

//跨浏览器获取视口(可视范围的页面窗口)
var width=window.innerWidth; //window.必须有,因为IE不支持
var height=window.innerHeight; //如果支持inner的,那么就使用它,
不支持的就使用document对象的方法

if(typeof width !='number'){ //IE
if(document.compatMode=='CSS1Compat'){ //如果是标准模式
width=document.documentElement.clientWidth;
height=document.body.clientHeight;
}else {
width=document.documentElement.clientWidth;
height=document.body.clientHeight;
}
}

 

了解
moveTo(100,100);
moveBy(10,10);

resizeTo(300,300); //调整浏览器大小,和上面一样
resizeBy(-10,-10);

posted @ 2017-08-15 14:10  耿鑫  阅读(165)  评论(0编辑  收藏  举报