title: JQuery: How to return to the exact same scroll position when going back to previous page
body: <p>I have a long list of items and when I clicked into each item and return to the main list, the scroll position was lost.</p>
  
  <p>How can I return to the same exact scroll position using jQuery? Is there any easy way to do it?</p>
  
  <pre><code>$(document).ready(function() {
  
    $('.update-button').click(function (){
      sessionStorage.scrollPos = $(window).scrollTop();
      console.log(sessionStorage.scrollPos);
    });
  });
  
  var init = function () {
      //get scroll position in session storage
      $(window).scrollTop(sessionStorage.scrollPos || 0)
  };
  window.onload = init;
  </code></pre>
  
  <p>Above is what my code looks like. I tried to log the position and sessionStorage.scrollPos was 0. I am pretty sure I scrolled the page to somewhere.</p>
  
  <p>Help is greatly appreciated.</p>