Html static page position after refresh

I have a page where I would like it to remain static after the update and not return back to the top page again, as it violates the position that I was last viewing. So I scroll down all the time to find the area that I last looked at. Is there a way to eliminate the drag of scrolling down again?

+4
source share
2 answers

Here is an example of saving scroll position using PHP .

Here is an example for ASP.NET .

If this is not enough, a google search to “keep the scroll position” will provide many more examples.

+1
source

Sorry, I removed the blog mentioned above (seen in the redirect statistics), but the message is still available from archive.org: http://web.archive.org/web/20050508195342/patrickfoley.com/2005/01/21/ scroll-saver /

Here is a complete PHP example from this page:

<HTML> <HEAD> <TITLE>Test</TITLE> <script> function SaveScrollXY() { document.Form1.ScrollX.value = document.body.scrollLeft; document.Form1.ScrollY.value = document.body.scrollTop; } function ResetScrollPosition() { var hidx, hidy; hidx = document.Form1.ScrollX; hidy = document.Form1.ScrollY; if (typeof hidx != 'undefined' && typeof hidy != 'undefined') { window.scrollTo(hidx.value, hidy.value); } } </script> </HEAD> <BODY onload="ResetScrollPosition()"> <form name="Form1" id="Form1" method="post" onsubmit="SaveScrollXY()" action="index.php"> <input name="ScrollX" id="ScrollX" type="hidden" value="<?php echo $_REQUEST['ScrollX'] ?>" /> <input name="ScrollY" id="ScrollY" type="hidden" value="<?php echo $_REQUEST['ScrollY'] ?>" /> <p>This is just a paragraph to make a very long page.</p><P>This is just a paragraph to make a very long page.</P> <P> <input name="TextBox1" type="text" value="<?php $v = $_REQUEST['TextBox1']; echo $v ? $v + 1 : 1 ?>" readonly="readonly" id="TextBox1" /></P> <P> <input type="submit" name="Button1" value="Post Form" id="Button1" /></P> </form> </BODY> </HTML> 
+2
source

All Articles