470,565 Members | 2,269 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,565 developers. It's quick & easy.

Reset a DIV - scroll to top

Joe
I have a very simple need - I need javascript code to reset a DIV that
the user may have scrolled down. It doesn't need to smoothly scroll or
anything - just jump right to the top.

All help gratefully received.
Joe
Jul 20 '05 #1
4 40718
depending on your specific context the solution maybe less or more complex
;-)

anyway ... perhaps one of the good old 2.0 tricks: <a
href="#target">top</a><a name="target"></a>
Pieter.

"Joe" <jb*********@hotmail.com> wrote in message
news:64**************************@posting.google.c om...
I have a very simple need - I need javascript code to reset a DIV that
the user may have scrolled down. It doesn't need to smoothly scroll or
anything - just jump right to the top.

All help gratefully received.
Joe

Jul 20 '05 #2
Joe
But wouldn't that require the user to click?

I want to be able to reuse a DIV that a user may already have
activated on the page and scrolled down once.
If I hide it, then re-show it, it is still scrolled down. I want a way
to scroll it to the top every time it is hidden or shown.
"Pieter Van Waeyenberge" <p@foo.com> wrote in message news:<40*********************@news.skynet.be>...
depending on your specific context the solution maybe less or more complex
;-)

anyway ... perhaps one of the good old 2.0 tricks: <a
href="#target">top</a><a name="target"></a>
Pieter.

"Joe" <jb*********@hotmail.com> wrote in message
news:64**************************@posting.google.c om...
I have a very simple need - I need javascript code to reset a DIV that
the user may have scrolled down. It doesn't need to smoothly scroll or
anything - just jump right to the top.

All help gratefully received.
Joe

Jul 20 '05 #3
But wouldn't that require the user to click?

I want to be able to reuse a DIV that a user may already have
activated on the page and scrolled down once.
If I hide it, then re-show it, it is still scrolled down. I want a way
to scroll it to the top every time it is hidden or shown.
"Pieter Van Waeyenberge" <p@foo.com> wrote in message news:<40*********************@news.skynet.be>...
depending on your specific context the solution maybe less or more complex
;-)

anyway ... perhaps one of the good old 2.0 tricks: <a
href="#target">top</a><a name="target"></a>
Pieter.

"Joe" <jb*********@hotmail.com> wrote in message
news:64**************************@posting.google.c om...
> I have a very simple need - I need javascript code to reset a DIV that
> the user may have scrolled down. It doesn't need to smoothly scroll or
> anything - just jump right to the top.
>
> All help gratefully received.
> Joe

Not sure if it is this what you're after:
---------8<--------8<--------8<--------
<script language='javascript'>

function move_up() {
scroll_clipper.scrollTop = 0;
}

</script>

<a href='javascript:move_up()'>Move UP</a>

<p>

<div id='scroll_clipper'
style='position:absolute; width:150px; height: 150px; overflow:auto'>
<div id='scroll_text' style='background-color:yellow'>
Here is some content that can be scrolled.
<p>It uses two divs:<ul>
<li>scroll_clipper, and
<li>scroll_text
</ul>

scroll_clipper defines the scroll area while scroll_text
defines the text to be scrolled.

</div>
</div>

---------8<--------8<--------8<--------

hth
Rene

--
Rene Nyffenegger
http://www.adp-gmbh.ch
Jul 20 '05 #4
Joe
That's exactly what I wanted - thanks!!
Rene Nyffenegger <re**************@gmx.ch> wrote in message news:<c0*************@ID-82536.news.uni-berlin.de>...
But wouldn't that require the user to click?

I want to be able to reuse a DIV that a user may already have
activated on the page and scrolled down once.
If I hide it, then re-show it, it is still scrolled down. I want a way
to scroll it to the top every time it is hidden or shown.
"Pieter Van Waeyenberge" <p@foo.com> wrote in message news:<40*********************@news.skynet.be>...
depending on your specific context the solution maybe less or more complex
;-)

anyway ... perhaps one of the good old 2.0 tricks: <a
href="#target">top</a><a name="target"></a>
Pieter.

"Joe" <jb*********@hotmail.com> wrote in message
news:64**************************@posting.google.c om...
> I have a very simple need - I need javascript code to reset a DIV that
> the user may have scrolled down. It doesn't need to smoothly scroll or
> anything - just jump right to the top.
>
> All help gratefully received.
> Joe

Not sure if it is this what you're after:
---------8<--------8<--------8<--------
<script language='javascript'>

function move_up() {
scroll_clipper.scrollTop = 0;
}

</script>

<a href='javascript:move_up()'>Move UP</a>

<p>

<div id='scroll_clipper'
style='position:absolute; width:150px; height: 150px; overflow:auto'>
<div id='scroll_text' style='background-color:yellow'>
Here is some content that can be scrolled.
<p>It uses two divs:<ul>
<li>scroll_clipper, and
<li>scroll_text
</ul>

scroll_clipper defines the scroll area while scroll_text
defines the text to be scrolled.

</div>
</div>

---------8<--------8<--------8<--------

hth
Rene

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Simon Wigzell | last post: by
2 posts views Thread by Paradigm | last post: by
3 posts views Thread by rmunson8 | last post: by
6 posts views Thread by C. Moya | last post: by
1 post views Thread by Mark | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.