views:

63

answers:

1

Hi,

I am executing the following javascript on my browser(firefox)

1.console.debug("Screen height = "+ screen.availHeight); //output 770

2.console.debug("Window Height ="+ $(window).height()); //output 210 (i am using jQuery as well)

What is the difference between the two? Are units of 770 is pixels and 210 is mm ?

Similarly, when I write $(document).height() and $(window).height() , there is a difference . What is the reason ?

+2  A: 
  • screen.availHeight is the height the Browser window can have if it is maximized. (incl all the window decoration of the browser like statusbar, menubars and titlebar)
  • $(window).height() is the height of the viewport that shows the webseite. (excl your toolbars and statusbar and stuff like this)
  • $(document).height() is the height of your document shown in the viewport. if it is higher than $(window).height() you get the scrollbars to scroll the document.

All values are pixels

update

the screen object has nothing todo with you website. Take a look at screen.height and screen.width. Do you recognize them? They are the pixels your display can display. screen.availHeight is screen.height minus Taskbar if you're on windows, minus Dock and Menubar if you're on a mac and minus whatever is fixed on top or bottom of your screen if you're using linux.

update2 here an image to show the differences: alt text

jigfox
I agree with your answer but then what is $(window).height() and why this value is different than screen.availHeight. I have already googled a lot over that but still no satisfactory answer. Further I see no documentation available which can tell the actual concept. By the way thanks for a super quick response. Thanks a lot again .
I've added an image to show the differences, I hope this will help.
jigfox
wow..Thanks a lot . Not many people put so much of effort for someone else query. Thanks again.
if my answer helped, I would appreciate it, if you accept my answer. That is how stackoverflow works.
jigfox