Jquery - tell when the hash changes?

后端 未结 5 964
野趣味
野趣味 2021-01-03 15:29

I\'m trying to make my site respond correctly to the back button. I\'ve saved that hash of what I want it to do, but I don\'t know the hook for jQuery to be able to tell wh

5条回答
  •  心在旅途
    2021-01-03 15:55

    Ben 'the cowboy' Alman wrote a cross platform plugin for hash changes

    http://benalman.com/news/2010/07/jquery-hashchange-event-v13/

    I dont know if your using it inside of the iframe or what, but if you were to use it outside the iframe it would be like

    $(function(){
        $(window).hashchange(function(){
           //Insert event to be triggered on has change.
           changeIframeContent(window.location.hash);
        })
    })
    

提交回复
热议问题