Jump to content

mormorchu

Member
  • Posts

    2
  • Joined

  • Last visited

Community Answers

  1. mormorchu's post in Need Help Returning to Same Place on Previous Page (Mobile) was marked as the answer   
    i tried this script too but it doesn't work to me. and i tried another script from another post with similar topic:
    <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>  it doesn't work to me too, then i try to ask ChatGPT what the script is about, it says: in a nutshell, this script refreshes the page every 35 seconds and then scrolls to the previous position. XD

    then i ask ChatGPT to rewrite the script for me, i paste it into footer section and finally works!!!!!
    here you are:
    <script type="text/javascript">
        // Store scroll position in history state when leaving the page
        window.addEventListener('beforeunload', function() {
            history.replaceState(scrollY, null, "");
        });
        // On page load, if there's a scroll position in history state, restore it
        window.addEventListener('load', function() {
            if (history.state !== null) {
                window.scrollTo(0, history.state);
            }
        });
    </script>
    try it!!!
    my website: www.mormorchu.com
    btw, i m also struggling on changing currency in the website so that customer can buy with their preferred currency, any people has good solution for that?
     
     
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.