clientHeight / clientWidth在不同的浏览器上返回不同的值 [英] clientHeight/clientWidth returning different values on different browsers

查看:301
本文介绍了clientHeight / clientWidth在不同的浏览器上返回不同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

属性 document.body.clientHeight document.body.clientWidth 在IE7,IE8和Firefox上返回不同的值:

Properties document.body.clientHeight and document.body.clientWidth return different values on IE7, IE8 and Firefox:

IE 8:

document.body.clientHeight : 704 
document.body.clientWidth  : 1148

IE 7:

document.body.clientHeight : 704 
document.body.clientWidth  : 1132

FireFox:

document.body.clientHeight : 620 
document.body.clientWidth  : 1152

为什么会出现这种差异?

是否有任何与不同浏览器(IE8,IE7,FireFox)一致的等效属性?

Why does this discrepancy exist?
Are there any equivalent properties that are consistent across different browsers (IE8, IE7, FireFox)?

推荐答案

浏览器盒模型。使用像jQuery或另一个JavaScript抽象库来标准化DOM模型。

This has to do with the browser's box model. Use something like jQuery or another JavaScript abstraction library to normalize the DOM model.

这篇关于clientHeight / clientWidth在不同的浏览器上返回不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆