Jquery +最新的哈希更改侦听器?
在 Google 和此处搜索但找不到任何其他插件。
或者仅使用此代码来针对大多数浏览器就足够了吗?
$(window).bind('hashchange', function() {
//code
});
编辑: 似乎这些浏览器上的 console.log()
存在问题,并且与 hashchange 无关。删除所有 console.log
输出后,它的工作方式与预期一致
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在使用的插件仍然是最好的插件。有关 IE9 支持,请查看此。还可以考虑为不支持哈希更改事件的浏览器提供一些替代方案(这可能会有所帮助)。
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).
如果任何网址更改都有效,您可以查看 history.js 但您可能应该测试本机支持并在存在的地方使用本机事件,并使用该插件修复不支持本机事件的旧浏览器,这就是您引用的插件的设计目的。
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.