jQuery - hashchange事件 [英] jQuery - hashchange event
本文介绍了jQuery - hashchange事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用:
$(window).bind( 'hashchange', function(e) { });
将函数绑定到散列更改事件。这似乎适用于IE8,Firefox和Chrome,但不适用于Safari,我认为不是早期版本的IE。对于这些浏览器,我想禁用使用哈希和 hashchange
事件的JavaScript代码。
to bind a function to the hash change event. This seems to work in IE8, Firefox and Chrome, but not in Safari and I assume not in earlier version of IE. For these browsers, I want to disable my JavaScript code that uses the hash and hashchange
event.
如果浏览器支持 hashchange
事件,我可以检测到jQuery吗?也许 jQuery.support
...
Is there a way with jQuery that i can detect if the browser supports the hashchange
event? Maybe something with jQuery.support
...
推荐答案
你可以检测到的东西如果浏览器支持该事件:
You can detect if the browser supports the event by:
if ("onhashchange" in window) {
//...
}
参见:
- Detecting event support without browser sniffing
- Emulating
onhashchange
without setInterval window.onhashchange
这篇关于jQuery - hashchange事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文