clientHeight/clientWidth returning different values on different browsers

nmdr picture nmdr · May 7, 2009 · Viewed 124.5k times · Source

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

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

Answer

arajek picture arajek · Sep 15, 2009

Paul A is right about why the discrepancy exists but the solution offered by Ngm is wrong (in the sense of JQuery).

The equivalent of clientHeight and clientWidth in jquery (1.3) is

$(window).width(), $(window).height()