Results 1 to 6 of 6

Thread: Resetting the scroll position after submit

  1. #1
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Resetting the scroll position after submit

    Is there a way to get the scroll to return to it's last position after a form is submited.
    I guess this could be made by anchor, but is there a way to do this whitout anchor. I also guess it could be made in ASP, but I use php and Linux.

    Any ideas?

    Thanks,
    Fredrik

  2. #2
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default Yes.

    It it possible. Use this script in the script section of some html:

    Code:
    <script language="JavaScript">
    function scroll_up()
    {
    window.scroll(0,0);
    }
    </script>
    Hope it helps.

    -magicyte

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I think that he wants it to return to the position when the from submits.
    Also, you may want to use scrollTo it's the new version of scroll.
    Adding to your code:
    HTML Code:
    <form onsumbit="scroll_up()">
    Jeremy | jfein.net

  4. #4
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    Here, this might be what you are looking for:
    http://www.sitepoint.com/article/pre...croll-position
    It uses ColdFusion to transmit the coordinates, but can also be rewritten to be completely client side.
    Last edited by DimX; 06-24-2008 at 08:06 PM. Reason: typo

  5. #5
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    I have a question, Nile. How do you use the latest version of scrollTo()? I still have Mozilla 4.0 (IE 4) and all I know what to do is window.scroll(coordinate,coordinate). Please reply.

    -magicyte

  6. #6
    Join Date
    Feb 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi all,

    There is a really simple way to do it. You can use <a name="anchor_name" /> element and set the url of your action to "your_form.html#anchor_name".

    See http://www.w3schools.com/HTML/html_links.asp or http://www.w3.org/TR/REC-html40/struct/links.html for more explanations.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •