Overlay positioning

Posted: 8 July 2010 in Firefox, Internet Explorer, Javascript
Tags: , , , , , , ,

I had to fix the overlay positioning, or more to the point, make sure that the dimmer behind the overlay stretched over the whole document. To do that, I had to do the following:

function getDocumentHeight(){
 if (document.documentElement && document.documentElement.scrollHeight && document.body && document.body.scrollHeight){
 return(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight));
 }
 if (document.documentElement && document.documentElement.scrollHeight ){
 return(document.documentElement.scrollHeight);
 }
 if (document.body && document.body.scrollHeight){
 return(document.body.scrollHeight);
 }
 return(0);
}
function getDocumentWidth(){
 if (document.documentElement && document.documentElement.scrollWidth && document.body && document.body.scrollWidth){
 return(Math.max(document.documentElement.scrollWidth,document.body.scrollWidth));
 }
 if (document.documentElement && document.documentElement.scrollWidth ){
 return(document.documentElement.scrollWidth);
 }
 if (document.body && document.body.scrollWidth){
 return(document.body.scrollWidth);
 }
 return(0);
}

This works in IE6, IE7, Opera, Chrome, Firefox.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s