jquery $(window).width() and $(window).height() return different values when viewport has not been r

Posted by Manca Weeks on Stack Overflow See other posts from Stack Overflow or by Manca Weeks
Published on 2010-04-07T23:29:55Z Indexed on 2010/04/07 23:33 UTC
Read the original article Hit count: 260

Filed under:
|
|

I am writing a site using jquery that repeatedly repeatedly calls $(window).width() and $(window).height() to position and size elements based on the viewport size...

In troubleshooting I discovered that I am getting slightly different viewport size reports in repeated calls to the above jquery functions when the viewport is not resized...

Wondering if there is any special case anyone knows of when this happens, or if this is just the way it is. The difference in sizes reported are 20px or less, it appears. It happens in Safari 4.0.4, Firefox 3.6.2 and Chrome 5.0.342.7 beta on Mac OS X 10.6.2... I didn't test other browsers yet because it doesn't appear to be specific to the browser. I was also unable to figure out what the difference depends upon - if it isn't the viewport size, could there be another factor that makes the results differ?

Any insight would be appreciated...

Thanks

MAnca

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about width