原文地址: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
{
this
.viewportWidth(), height:
this
.viewportHeight() };
12.
}
13.
};