Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you use JavaScript, this code will do the trick.</p> <pre><code>var cookieName = "page_scroll"; var expdays = 365; // An adaptation of Dorcht's cookie functions. function setCookie(name, value, expires, path, domain, secure) { if (!expires) expires = new Date(); document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : "; expires=" + expires.toGMTString()) + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + ((secure == null) ? "" : "; secure"); } function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i &lt; clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { return getCookieVal(j); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function getCookieVal(offset) { var endstr = document.cookie.indexOf(";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function deleteCookie(name, path, domain) { document.cookie = name + "=" + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + "; expires=Thu, 01-Jan-00 00:00:01 GMT"; } function saveScroll() { var expdate = new Date(); expdate.setTime(expdate.getTime() + (expdays*24*60*60*1000)); // expiry date var x = document.pageXOffset || document.body.scrollLeft; var y = document.pageYOffset || document.body.scrollTop; var data = x + "_" + y; setCookie(cookieName, data, expdate); } function loadScroll() { var inf = getCookie(cookieName); if (!inf) { return; } var ar = inf.split("_"); if (ar.length == 2) { window.scrollTo(parseInt(ar[0]), parseInt(ar[1])); } } </code></pre> <p>This works by using a cookie to remember the scroll position.</p> <p>Now just add</p> <pre><code>onload="loadScroll()" onunload="saveScroll()" </code></pre> <p>to your body tag and all will be well.</p> <p><strong>Source(s):</strong> <a href="http://www.huntingground.freeserve.co.uk/main/mainfram.htm?../scripts/cookies/scrollpos.htm" rel="nofollow noreferrer">http://www.huntingground.freeserve.co.uk/main/mainfram.htm?../scripts/cookies/scrollpos.htm</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload