Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to force a scroll of div with overflow set to auto?

Reply
Thread Tools

How to force a scroll of div with overflow set to auto?

 
 
Martin
Guest
Posts: n/a
 
      02-18-2010
I don't know if this is a javascript question or just html related.

I'm displaying a table of data in a div with overflow set to "auto"
(with a vertical scrollbar being used). Is there any way I can make it
scroll down a certain distance?

Here's the situation: the user gets the page and he manually scrolls
down into the list. He finds what he's looking for and then clicks on
a row in the table which requests a refresh of the page with some
additional data being shown (elsewhere on the page). When this
refreshed page comes in, I'd like to automatically scroll him down to
where he was when he clicked.

Possible?



 
Reply With Quote
 
 
 
 
Scott Sauyet
Guest
Posts: n/a
 
      02-18-2010
On Feb 18, 11:47*am, Martin <(E-Mail Removed)> wrote:
> Here's the situation: the user gets the page and he manually scrolls
> down into the list. He finds what he's looking for and then clicks on
> a row in the table which requests a refresh of the page with some
> additional data being shown (elsewhere on the page). When this
> refreshed page comes in, I'd like to automatically scroll him down to
> where he was when he clicked.


Have you tried scrollIntoView()? [1] It's not part of a spec, but I
believe it's widely supported. I don't know if it will scroll your
table as well as the page, but it's worth trying.

Good luck,

-- Scott
____________________
[1] https://developer.mozilla.org/En/DOM...scrollIntoView
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      02-18-2010
On Feb 18, 4:47 pm, Martin wrote:
> I don't know if this is a javascript question or just
> html related.


If you cannot decide that for yourself what makes you think you are
qualified to be designing/building a system like this?

> I'm displaying a table of data in a div with overflow set
> to "auto" (with a vertical scrollbar being used). Is there
> any way I can make it scroll down a certain distance?


Scripts can alter the distance by which an overflow auto DIV is
scrolled by assigning to the Element's - scrollTop - property
(negative values to scroll down) (or - scrollLeft - if left/right
scrolling is wanted).

> Here's the situation: the user gets the page and he manually
> scrolls down into the list. He finds what he's looking for
> and then clicks on a row in the table which requests a refresh
> of the page with some additional data being shown (elsewhere
> on the page). When this refreshed page comes in, I'd like to
> automatically scroll him down to where he was when he clicked.


In which case scrolling some certain distance requires that you find
out that distance in some way (probably reading the current value from
the element's - scrollTop - value prior to submitting).

It is possible, depending on the mark-up and the mechanisms employed,
that a system based on fragment identifiers could be used here, and so
have the browser do all the work whithout and scripting involved.

Richard.
 
Reply With Quote
 
Jorge
Guest
Posts: n/a
 
      02-18-2010
On Feb 18, 6:07*pm, Richard Cornford <(E-Mail Removed)>
wrote:
>
> If you cannot decide that for yourself what makes you think you are
> qualified to be designing/building a system like this?


I guess you were born knowing everything you know now, but we -the
rest of the people- have had to learn. Sometimes, in the process, we
ask others for help.
--
Jorge.
 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      02-18-2010
On Thu, 18 Feb 2010 09:07:21 -0800 (PST), Richard Cornford
<(E-Mail Removed)> wrote:

>On Feb 18, 4:47 pm, Martin wrote:
>> I don't know if this is a javascript question or just
>> html related.

>
>If you cannot decide that for yourself what makes you think you are
>qualified to be designing/building a system like this?
>
>> I'm displaying a table of data in a div with overflow set
>> to "auto" (with a vertical scrollbar being used). Is there
>> any way I can make it scroll down a certain distance?

>
>Scripts can alter the distance by which an overflow auto DIV is
>scrolled by assigning to the Element's - scrollTop - property
>(negative values to scroll down) (or - scrollLeft - if left/right
>scrolling is wanted).
>
>> Here's the situation: the user gets the page and he manually
>> scrolls down into the list. He finds what he's looking for
>> and then clicks on a row in the table which requests a refresh
>> of the page with some additional data being shown (elsewhere
>> on the page). When this refreshed page comes in, I'd like to
>> automatically scroll him down to where he was when he clicked.

>
>In which case scrolling some certain distance requires that you find
>out that distance in some way (probably reading the current value from
>the element's - scrollTop - value prior to submitting).
>
>It is possible, depending on the mark-up and the mechanisms employed,
>that a system based on fragment identifiers could be used here, and so
>have the browser do all the work whithout and scripting involved.
>
>Richard.


Thank you - in spite of the un-needed, snide remark about my
qualifications.

I was not aware of the scrollTop property. Learning about it enabled
me to do exactly what I wanted to.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Nike air force one, air force 1, air force one low cut, air force one abdul_razak@indiatimes.com Digital Photography 2 12-31-2008 04:29 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:34 PM
div overflow doesn't scroll in Safari hanness@gmail.com Javascript 1 03-11-2007 08:36 PM
Monitoring of a vertical scroll within a <div style='overflow: auto height:300px;'> yellowtek Javascript 1 09-11-2006 07:29 PM



Advertisments