Forum Moderators: open

Message Too Old, No Replies

Scrolling More than one DIV tag at Once

automatically scrolling more than one div tag

         

actionscripter

11:11 pm on Jan 17, 2008 (gmt 0)

10+ Year Member



I'm using a script where multiple div tags are populated. I have been successful in getting content populated into 1 div tag to auto scroll. My question is, How you get contents from multiple divs to scroll automatically.

Can I encapsulate all the div tags into one DIV with overflow and the scorlling script applied to it?

Here's the scrolling code i'm using is there any way to apply it to a certain div tag that would hold all the other div tags?

i.e.


<div id="scrollingDIV" onFocus="scrollingFunction">
<div></div>
<div></div>
</div>

functionScrolling()
//Scrolling

{
var currentScrollHeight = obj.scrollHeight;
if (currentScrollHeight >= parseInt(obj.style.height))
{
obj.scrollTop=(obj.scrollTop +100);
}
}

gergoe

7:03 pm on Jan 18, 2008 (gmt 0)

10+ Year Member



You can indeed embed the divs into one bigger div, and make that one scrolling instead of the smaller ones, you will need to play around with the css then. If you assign the onfocus to the outer div, then it will be triggered for the inside divs as well, as long as you do not define an onfocus for those divs. Alternatively you can make all the divs scrolling, but not only adjustnig the scrollTop of one of the divs, but all of them in the same function, something like this:

<div id="div1" onFocus="scrollingFunction();"></div> 
<div id="div2" onFocus="scrollingFunction();"></div>

// 
// Function to scroll all required divs
function scrollingFunction() {
scrollDiv(document.getElementById('div1'));
scrollDiv(document.getElementById('div2'));
}
//
// Function to scroll a particular div
function scrollDiv(obj) {
var currentScrollHeight = obj.scrollHeight;
if (currentScrollHeight >= parseInt(obj.style.height)) {
obj.scrollTop = obj.scrollTop + 100;
}
}