第一种:
function pushHistory(returnUrl, currentUrl, currentTitle) {
window.addEventListener("popstate", function (e) {
window.location.href = returnUrl;
}, false);
var state = {
title: currentTitle,
url: currentUrl
};
window.history.pushState(state, currentTitle, currentUrl);
}
pushHistory("map.jsp","detail.jsp","详情");
returnUrl 是需要返回的页面地址
currentUrl是当前页面地址
currentTitle是当前页面的标题
第二种:
/*-----监听返回事件-----*/
$(function(){
pushHistory();
window.addEventListener("popstate", function(e) {
alert('监听到了返回事件')
pushHistory();
}, false);
function pushHistory() {
var state = {
title: "title",
url: "#"
};
window.history.pushState(state, "title", "#");
}
});
这个适用于iframe加载页面监听返回
第三种:
self.location=document.referrer;
超级简单的一种