JavaScript获得页面区域大小的代码

原文地址:http://andrewdupont.net/2006/09/09/viewport-dimensions-in-javascript/

一个JavaScript获得页面区域大小的代码,兼容性很好!

01. var Client = {
02.      viewportWidth: function() {
03.        return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
04.      },
05.   
06.      viewportHeight: function() {
07.        return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
08.      },
09.   
10.      viewportSize: function() {
11.        return { width: this.viewportWidth(), height: this.viewportHeight() };
12.      }
13.     };
posted @ 2009-07-30 17:10  awp110  阅读(184)  评论(0编辑  收藏  举报