ScottoCat Posted August 29, 2023 Posted August 29, 2023 Hello, Once again script has stopped working on my site. It is one of the most important features. I guess every time they do an update? Because there is a lot of scrolling with many individual posts I need the user to return to where they were on the posts page when they click the back arrow. I found script that works BUT only after the 2nd click back. I need it to happen every time. Is there a way to alter this or does anyone have script that would work.? Thanks! Here It is: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script type="text/javascript"> if (window.performance && window.performance.navigation.type === window.performance.navigation.TYPE_BACK_FORWARD) { if (localStorage.getItem("my_app_name_here-quote-scroll") != null) { $(window).scrollTop(localStorage.getItem("my_app_name_here-quote-scroll")); } } else { $(window).scrollTop(); } window.addEventListener('beforeunload', function (e) { if (window.performance && window.performance.navigation.type === window.performance.navigation.TYPE_BACK_FORWARD) { localStorage.setItem("my_app_name_here-quote-scroll", $(window).scrollTop()); } }); </script>
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment