DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

John has posted 18 posts at DZone. View Full User Profile

Determine Screen Height

08.14.2008
| 9169 views |
  • submit to reddit
        // description of your code here

..normally

var h = document.documentElement.scrollHeight;

..however in some cases (safari 3) you may have to find where something is on the screen and generate the actual screen size around that
if (($('lightbox_bottom').cumulativeOffset().top+30) > document.documentElement.scrollHeight) {
  $('sBg').style.height=$('lightbox_bottom').cumulativeOffset().top+30+'px';
}
else {
  $('sBg').style.height=document.documentElement.scrollHeight+'px';
}

30 being the height of the bottom element your using to judge.