The popState
event will be triggered when the url has changed (either back or forward). And recently I have noticed that, for example, in http://www.example.com/
:
<a href="#anchor">Top</a>
will also trigger popState
, causing the page to "reload".
How can I know that if it is the same url and only the #
part has changed?
$(window).bind("popstate",function(){
swap(location.href);
})
In the example, when you click on "Top" link (see above), the page will go to #anchor
, but also it will trigger popState
and causes reloading, which is I do not expect.