title: Save scroll position on click and then retrieving?
body: <p>I am trying to write a function in jquery that when a button is clicked, the user's scroll position is saved, and then when the page loads the link that the button directed to, the scroll position is retrieved.  Here is my function.  I am not sure what the problem is as I am relatively new to this.</p>
  
  <pre><code>var scrolltop;
  
  $(document).ready(function(){
   $('a.page-numbers').click(function() {
    scrolltop = $(document).scrollTop(); // store it
    var href = $(this).attr('href'); 
    window.location= href; // I am doing this to force a button to go to a link and temporarily fix a pagination issue if people are curious.  Not the current issue at hand.
    return false; // Doing this so page doesn't scroll on click
   });
  });
  
  $(document).ready(function(){
   $('html, body').animate({scrollTop: scrolltop}); //not scrolling to where saved
  });
  </code></pre>
  
  <p>Bonus points for anyone who can also make it mobile (ios, Android, etc.) compatible :)</p>