Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is $(window).height() so wrong?

Tags:

jquery

I'm trying to get the current browser viewport height, using

$(window).on('resize',function() { 
  console.log("new height is: "+$(window).height()); 
});

But I'm getting values that are way too low. When the viewport is around 850px tall, I'm getting values around 350 or 400px from height(). What's up?

Example: http://jsfiddle.net/forgetcolor/SVqx9/

like image 246
mix Avatar asked Sep 11 '25 04:09

mix


1 Answers

I was having the same problem in Firefox then I added <!DOCTYPE HTML> on my index and it worked.

Source: http://viralpatel.net/blogs/jquery-window-height-incorrect/

like image 145
Nilson Morais Avatar answered Sep 12 '25 21:09

Nilson Morais