javascript获得浏览器工作区域的大小

浏览器的窗口发生变化时会执行window.onresize方法,通过这个方法我们可以获得到浏览器工作区域的大小:

1 window.onresize=function(){ 
2     bodyHeight = window.innerHeight?(window.innerHeight<600?600:window.innerHeight):document.documentElement.clientHeight;
3     bodyWidth = window.innerWidth?window.innerWidth:document.body.offsetWidth;
4 };

 

posted @ 2014-04-10 17:13  尐sんΙ頭  阅读(260)  评论(0)    收藏  举报