使用Ajax,并试图使用.document对象创建实际的Ajax页面上popstate事件处理程序:的addEventListener(“popstate”)未烧制.document
document.addEventListener("popstate", myPopState);
不幸的是,这并不永远似乎触发。
我的意图是,页面重新加载后,popstate事件触发器会自动消失。
使用Ajax,并试图使用.document对象创建实际的Ajax页面上popstate事件处理程序:的addEventListener(“popstate”)未烧制.document
document.addEventListener("popstate", myPopState);
不幸的是,这并不永远似乎触发。
我的意图是,页面重新加载后,popstate事件触发器会自动消失。
阿贾克斯成功响应里面,你可以使用
var msg="Any thing which u want";
var customUrl ="www.stackoverflow.com";
window.history.pushState({"html":msg,"pageTitle":"My Title"},"", customUrl);
window.onpopstate = function(event) {
alert('back is clicked');
// what ever u want
}
UPDATE
$(window).unload(function(e){
e.preventDefault();
$(window).trigger('beforeunload');
});
$(window).bind('beforeunload',function(){
alert('call your ajax here');
return '';
});
'window.addEventListener( “popstate”,myPopState);' – zer00ne