View Full Version : detecting scroll-bars on DIV

07-22-2004, 01:34 PM
Hi all,

I having a wrapper DIV (certain width say 400px) and i have some child DIVS which i want to add to it. And i want it to have a maximum height of 600px say.

I DONT want the wrapper DIV to have vertical scroll bars so i would like to add as many child DIVS (which contain text of indiscriminant length) until i can somehow detect that the wrapper has overflowed (ie the scrollbars have been implemented !) if it has then remove the last one and dynmically create a new DIV, and continue the cyclw until exhausted of child DIVS.

Have i explained it lucidly enuf? Hope so :confused:


(Question 1)

Is it possible to detect 'on the fly' that a DIV has acquired scroll bars? and if so how !!

(Question 2) Related

if i have a wrapper div, say with id wrapperDiv (amazing imagination ;) ), populated with child divs, childDiv1, childDiv2, childDiv3, (added using DOM)etc and a child div is not in view how can i scroll so a invisible div, not currently in view, comes to be displayed the top of the wrapperDiv?

I beleive i can use something like scrollTo?? I seem to be confused how to get a child element, specifically, to be moved to the top of the view :confused:

Thanx in advance

07-22-2004, 06:35 PM
I don't know the answer to question 2 (off hand..), but the answer to question 1 (I think..) is:
<div style="overflow:hidden;">

scrollTo uses coordinates, so if you can ensure that your child divs are always at some particular coordinate, then you might be able to get it to work. I'm not sure if scrollTo works in DIVs, you may need to use an iFrame..

Hope that helps,