View Full Version : Resetting the scroll position after submit
topfuel
06-16-2008, 09:40 PM
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
magicyte
06-24-2008, 06:49 PM
It it possible. Use this script in the script section of some html:
<script language="JavaScript">
function scroll_up()
{
window.scroll(0,0);
}
</script>
Hope it helps.
-magicyte
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:
<form onsumbit="scroll_up()">
Here, this might be what you are looking for:
http://www.sitepoint.com/article/preserve-page-scroll-position
It uses ColdFusion to transmit the coordinates, but can also be rewritten to be completely client side.
magicyte
06-25-2008, 01:59 AM
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
NicolasBlackburn
02-05-2009, 10:37 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.