browser back button is not updating page

后端 未结 3 754
说谎
说谎 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:49

    Older versions of IE don't support hashchange, so you have to cheat by using setInterval to poll a few times a second and check if it's changed.

    if($.browser.msie && $.browser.version < 7){
        setInterval(function(){
            if(window.location.hash != window.lastHash){
                hashChangeHandler();
                window.lastHash = window.location.hash;
            }
        }, 100);
    }
    else{
        $(window).bind('hashchange',function() {
            if (location.hash != '#visits') {
                hashChangeHandler();
            }
        }
    }
    

提交回复
热议问题