473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 41004
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Simon Wigzell | last post by:
I want to display HTML text inside a div and have the page open scrolled to the bottom. (My div has overflow:auto so that it appears with scroll bars) I have found this that works on a textarea:...
2
by: Paradigm | last post by:
I have a number of text boxes on a number of forms and I cannot get the scroll bars to display. The text boxes have the scrollbars property set to vertical. I can use the cursor keys to scroll up...
3
by: Ben | last post by:
Hi, I have a page with a datagrid that you have to scroll to see. I'm using the StrengthControls SmartScroller as recommended to maintain my scroll position. Anyway, inside the datagrid I have...
3
by: rmunson8 | last post by:
I have added Panel control to a web page which contains a GridView. The Panel's ScrollBars property is set to auto. When I select the Select CommanField button for a row (which obviously causes a...
0
by: Chris Rathman | last post by:
Setting MaintainScrollPositionOnPostBack=true gets me the behavior I most often want, but there are times when I need to have the scroll position return to the top of the page - instead of the last...
6
by: C. Moya | last post by:
I hope someone has an answer: MaintainScrollPositionOnPostback works great. But, the problem is that sometimes we need to manually reset the scroll position back to the top (such as when hiding a...
4
tpgames
by: tpgames | last post by:
I need a code that forces all people's firefox browsers to give them a horizontal scroll bar regardless of what their tool bars and other factors tell the browser to do. I have a crossword puzzle...
1
by: Mark | last post by:
Hi. I have a page which has an update panel covering all of it. When I do a server postback via the update panel, the screen remains in the same scroll position - which is ok most of the time....
12
Frinavale
by: Frinavale | last post by:
I think I'm trying to do something impossible. I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.