View Full Version : getting the document or table height
raoul
10-19-2002, 09:27 AM
Hi,
I have a dynamic page in a popup window and would like to adjust the size of the window depending on the height of the document inside the window.
How can the actual height of a document or a table be detected?
Thanks!
Raoul
Graeme Hackston
10-19-2002, 03:53 PM
element:
document.getElementById('my-element').offsetHeight
document (I think):
document.body.scrollHeight
I can't help you with sizing pop ups but I think you would need the sizes you want before the window is opened
raoul
10-19-2002, 04:16 PM
Thanks Graeme!
I tried offsetheight but that returns the size of the current window. scrollHeight, however, does return the right size. Does scrollHeight work crossbrowser?
One other question to make it work completely ok. To resize the window to the correct size it is necessary to add the height of the window top and bottom borders (it seems this is something around 30 for IE). Anyone knows the correct numbers for other browsers?
regards,
Raoul
Graeme Hackston
10-19-2002, 05:01 PM
AFAIK scrollHeight works with IE5+ and NN6+ (maybe Opera 6 onload?)
I don't know about border sizes.
adios
10-19-2002, 05:50 PM
IE4+:
document.body.scrollHeight
NS4+:
document.height
Opera5+:
document.body.scrollHeight
You can use window.outerHeight in NS/moz/Opera, as a browser property and in window.open('','','outerHeight=400,...) itself. It correctly refers to the window's outer (vertical) dimensions.
http://www.mozilla.org/docs/dom/domref/dom_window_ref78.html
raoul
10-19-2002, 09:00 PM
Thanks both,
works great!
Raoul
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.