Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search

kylejcho

Member
  • Posts

    1
  • Joined

  • Last visited

Posts posted by kylejcho

  1. On 6/18/2020 at 2:08 PM, colin.simmons said:

    Hey friends, 

    Here's a snippet of code that I use to save the scroll position. I use it when a user has navigated away from a long index page and I want them to return to the same place.

    Note, for an index, you must add it in the code injection for the INDEX, not the page section. 

    
    <script type="text/javascript">
      function refreshPage () {
          var page_y = document.getElementsByTagName("body")[0].scrollTop;
          window.location.href = window.location.href.split('?')[0] + '?page_y=' + page_y;
      }
      window.onload = function () {
          setTimeout(refreshPage, 35000);
          if ( window.location.href.indexOf('page_y') != -1 ) {
              var match = window.location.href.split('?')[1].split("&")[0].split("=");
              document.getElementsByTagName("body")[0].scrollTop = match[1];
          }
      }
    </script>

    Let me know if this helps!

    I'm confused what I'm supposed to do with this code. Where do I paste it? In the "Code Injection" section?

×
×
  • Create New...