clientHeight/clientWidth returning different values on different browsers

前端 未结 9 1208
有刺的猬
有刺的猬 2020-11-27 19:14

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

IE 8:



        
相关标签:
9条回答
  • 2020-11-27 19:40

    It may be caused by IE's box model bug. To fix this, you can use the Box Model Hack.

    0 讨论(0)
  • 2020-11-27 19:43

    What I did to fix my issue with clientHeight is to use the clientHight of the controls firstChild. I use IE 11 to print labels from a database and the clientHeight that worked in IE 8 was returning the height of 0 in IE 11. I found a property in that control that was listed as firstChild and that had a property if clientHeight and actually had the height I was looking for. So if your control is returning a clientSize of 0 take a look at the property of its firstChild. It helped me...

    0 讨论(0)
  • 2020-11-27 19:47

    i had a similar problem - firefox returned the correct value of obj.clientHeight but ie did not- it returned 0. I changed it to obj.offsetHeight and it worked. Seems there is some state that ie has for clientheight - that makes it iffy...

    0 讨论(0)
提交回复
热议问题