473,327 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Which DOM property for determining vertical size?

I want to do my own vertical (or whatever direction) smooth expand of a
block element. The simple approach so far: create and fill container
element. Set element.style.height to 0px, overflow hidden, and use a
timeout callback to increase element.style.height, until it matches
element.scrollHeight. However, scrollHeight is MSDOM. Is there a W3C
compliant alternative? Or a smarter approach altogether?

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Jun 27 '08 #1
3 1462
Gregor Kofler wrote:
I want to do my own vertical (or whatever direction) smooth expand of a
block element. The simple approach so far: create and fill container
element. Set element.style.height to 0px, overflow hidden, and use a
timeout callback to increase element.style.height, until it matches
element.scrollHeight. However, scrollHeight is MSDOM. Is there a W3C
compliant alternative?
Somewhere in the future it might be an W3C standard:
http://www.w3.org/TR/cssom-view/#scroll-attributes

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
Gregor Kofler wrote:
I want to do my own vertical (or whatever direction) smooth expand of a
block element. The simple approach so far: create and fill container
element. Set element.style.height to 0px, overflow hidden, and use a
timeout callback to increase element.style.height, until it matches
element.scrollHeight. However, scrollHeight is MSDOM. [...]
_MSHTML DOM_. Nevertheless, Gecko/20080404 also supports it in Standards
Compliance Mode, and so do Opera/9.27 and Apple WebKit/525.13.

But, since you would probably want an approach that degrades gracefully, you
could store the `offsetHeight' property value before you resize the element,
if supported. Not standards compliant either, but supposedly better supported.
HTH

PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jun 27 '08 #3
Thomas 'PointedEars' Lahn meinte:
Gregor Kofler wrote:
>I want to do my own vertical (or whatever direction) smooth expand of a
block element. The simple approach so far: create and fill container
element. Set element.style.height to 0px, overflow hidden, and use a
timeout callback to increase element.style.height, until it matches
element.scrollHeight. However, scrollHeight is MSDOM. [...]

_MSHTML DOM_.
Hmmm... I somehow anticipated this remark. (On developer.mozilla.org
they call it MSIE DHTML object model, MSDN calls it DHTML DOM.)
Nevertheless, Gecko/20080404 also supports it in Standards
Compliance Mode, and so do Opera/9.27 and Apple WebKit/525.13.
But, since you would probably want an approach that degrades gracefully, you
could store the `offsetHeight' property value before you resize the element,
if supported. Not standards compliant either, but supposedly better supported.
I would use offsetHeight, if the element is visible in the beginning.
But since the element gets inserted as an "invisible" (display = "none")
childnode, offsetHeight isn't available (unless I haven't overlooked
something). Showing the element, reading offsetHeight, and turning it
off again isn't an option either, because of the flicker. Hacks like
offscreen-rendering, reading, relocation, etc. is something I try to
avoid. Rather scrollHeight then.

Gregor

--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Luca | last post by:
I have the following problem: I'm developing a system where there are some processes that communicate each other via message queues; the message one process can send to another process is as...
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
1
by: gibsonsgman | last post by:
I am having a problem with a vertical label. I change the label property 'vertical' to yes and then my label caption disappears and i cannot figure out why. any suggestions?
5
by: Jens | last post by:
Posted to: comp.periphs.printers comp.lang.c comp.lang.postscript Hello, I am looking for some publically available methods/algorithms or C source code for detecting
3
by: acunnon | last post by:
I am trying to put together an login page my problem is getting the three items aligned to the middle verticaly without specifing a height to anything on the page. CSS html{ height:100%;...
8
by: ayamopamo | last post by:
Hi- I am trying to center a web page. It seems like this should be very simple to do, but apparently it isn't my day. I have successfully centered the background by calling it in the css body tag:...
3
by: Gord | last post by:
If I have a form open with a subform control on it in datasheet view that has its record source set to a query or a table, is it possible to determine which record the user has clicked into with...
0
by: yatinbvn | last post by:
hi , my name is yatin i have creating swt text with vertical scroll bar in shell, my question is: vertical scroll bar thumb is still visible in swt text when its size is not increase , i want...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.