问题
I'm using http://benalman.com/projects/jquery-hashchange-plugin/ to listen for hash changes in my project, but his plugin is outdated and does not work with newer versions of browsers such as Firefox 9 and IE9.
Searched on Google and here but could not find any other plugin.
Or is it enough to just use this code to target most of the browsers?
$(window).bind('hashchange', function() {
//code
});
EDIT:
Seems like there was a problem regarding console.log()
on these browsers and had nothing to do with the hashchange. It works like expected after removing all console.log
output
回答1:
Plugin you are using is still the best one available. For IE9 support check out this. Also consider some alternative for browsers that do not support hash change event (this may help).
回答2:
If any url change would work, you might look at history.js But you should probably test for native support and use the native event where it exists, and use the plugin to fix older browsers that don't support the native event, which is what the plugin you referenced is designed to do.
来源:https://stackoverflow.com/questions/8908172/jquery-up-to-date-hash-change-listener