我想检测后退按钮单击事件,所以我在 jquery 中使用 window popstate 事件。但它根本没有在任何时候开火。
请参考下面的代码
$(document).ready(function(){
$(window).on("popstate",function(){
debugger
});
});
也试过这种方式。
window.onpopstate = function(event) {debugger
alert("location: " + document.location + ", state: " + JSON.stringify(event.state));
};
是否需要为此添加任何外部脚本?或其他任何需要在我的页面中配置的内容。