原文地址:
一个JavaScript获得页面区域大小的代码,兼容性很好!
[code=”javascript”]
?var Client = {
? ????viewportWidth: function() {
??? ????return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
? ????},
?
????? viewportHeight: function() {
??? ????return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
? ????},
?
? ????viewportSize: function() {
??? ????return { width: this.viewportWidth(), height: this.viewportHeight() };
? ????}
???? };
[/code]
使用:Client.viewportHeight();
这个挺实用,拿走,呵呵。