我有一个执行过滤器然后更改 url 的 ajax 函数。
我将如何执行以下等效操作:
$(window.location).change(function() {
alert('hello');
})
我有一个执行过滤器然后更改 url 的 ajax 函数。
我将如何执行以下等效操作:
$(window.location).change(function() {
alert('hello');
})
您可能会看一下历史 API。您可以使用该onhashchange
事件来检测该更改。
$(window).on('hashchange', function() {
alert('hello');
});
如果您更改位置,浏览器停止所有脚本并且不触发更改功能,您可以在使用更改位置时仅使用文档的卸载事件,请在此处查看http://api.jquery.com/unload/如果您只更改书签然后只处理hashchange
事件,你可以在这里找到示例 jquery 插件http://benalman.com/projects/jquery-hashchange-plugin/ ..