browser back button is not updating page

后端 未结 3 760
说谎
说谎 2021-01-28 21:08

I\'m setting the URL after the hashmark with a jquery click event. The URL is getting set properly but when I use the browsers back button it doesn\'t take me to the previous p

3条回答
  •  被撕碎了的回忆
    2021-01-28 21:37

    Use the onhashchange event of the window, to check if the hash changes. This is getting called when you hit the back Button of your browser.

    $(window).bind('hashchange',function() {
        if (location.hash != '#visits') {
            //Code to revert the changes on the page
        }
    }
    

提交回复
热议问题