Jump to content

scrollHeight returning different values inside a window.open and .showModalDialog


pointsys

Recommended Posts

I came across a very odd issue in a project and hope someone here would have some insight into WHY this is happening... Have googled for days and can't find this issue anywhere, but I find it hard to believe no one has come across it before...

 

We have a webpage (asp) which can result in a dynamic length, and we need to find out what the length of any particular presentation of this page is. Normally, this would be very simple by using the onload body.scrollHeight value.

 

In fact, when the page is loaded in a pop-up using window.open, the value of the scrollHeight is accurate. If we print the page, we can convert to mm using the formula sH / 96 *254 adjusting for a 96dpi resolution and 254mm/inch. The value in this formula is spot on every single time, accurate to within 1mm.

 

BUT... when the exact same page is loaded using the window.showModalDialog method, the scrollHeight values reported are different - and not in any mathematically consistent way. It is the same page and should have the same body.scrollHeight onload!!

 

Here are three examples of actual measured page length compared to the loading method and resulting scrollHeight:

 

measurement sH .open method sH .showModal Dialog method

952mm 360 px 344 px

1302mm 490 px 493 px

1682mm 661 px 637 px

 

BOTH methods are being called without any menus, scroll, or other adornment. The browser is IE in all cases, with the same printer for measured output of course. The ONLY difference in the reported values is coming from the method being used to load the page.

 

Needless to say, this is driving me nuts :-). Anyone have any ideas???

 

Thanks!

 

 

 

 

 

 

 

Link to comment
Share on other sites

I'm not sure what the issues with the modal window are, but I would suggest to try the other methods to get the height and see if you can get some consistency. e.g.:

 

var body = document.body,
    html = document.documentElement;

var height = Math.max( body.scrollHeight, body.offsetHeight, 
                       html.clientHeight, html.scrollHeight, html.offsetHeight );
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...