...

View Full Version : Vertical scrolling in a DIV



Mari
10-07-2003, 09:45 AM
Hi.
I use a DIV element to display a tree. The tree looks like the Window Explorer, with folders and +/- to go up or down in the tree. I use overflow: auto; to get scrollbars if the tree gets to big for the DIV.
My problem is:
I scroll down to a line and press for example + ,
the screen refreshes with data from my servlet. And the scrollbar starts at the top again.
I want to have position of the scrollbar at the point I was before the update.

Kor
10-08-2003, 09:00 AM
Try using DHTML scrolling methods scroll(x,y) or scrollTo(x,y) within an ID idetified object (your DIV)...

Try document.getEmentntById(id).scrollTo(x,y)

I haven't tasted but it might work

Kor
10-08-2003, 09:02 AM
getElementById

Mari
10-08-2003, 01:06 PM
Hi.
Thanks for the tip.
I use document.getElementById("id").scrollLeft = x
and document.getElementById("id").scrollTop = y
instead of scrollTo(x,y).
It seems to work.

Mari

wac
10-13-2003, 09:37 PM
Will this work w/ both NS6 and IE6? (only have one at work, but need to account for both eventually)

Mari
10-14-2003, 06:08 AM
Hi.
I have not tested in NS6 but I use the following:

var isIE = 0;
if( navigator.appName.indexOf('Microsoft Internet Explorer') != -1 ){isIE = 1;}

function scrollDIVTo(x,y){
if( isIE ){
document.getElementById("liste").scrollLeft = x;
document.getElementById("liste").scrollTop = y;
return;
}
else{
scrollTo( x,y );
return;
}
}

Mari.

wac
10-15-2003, 01:22 AM
I'm trying to scroll an element of a DIV into view.
Ive got a table with 40 rows within a scrollable div.

I tried

div.scrollTop = node.offsetTop

where node is a table cell within a scrollable div.
This works fine as long as the node is not close to the bottom of the table. But if the node is < div.clientHeight from the end of the div, the div.clientHeight is reduced. Its really crazy.

(I know node.offsetTop is the offset from the top of the table. There's nothing between the top of the table and the top of the div). I noticed that there's a scrollIntoView method, but unfortunately it scrolls the entire page and not just the div content. Has anyone done something like this?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum