By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,687 Members | 1,806 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,687 IT Pros & Developers. It's quick & easy.

Reset a DIV - scroll to top

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.