让浏览器返回按钮失效
让浏览器返回按钮失效
禁用登录页的浏览器返回按钮,防止退出后点击返回按钮再次进入后台页面
//禁用登录页的浏览器返回按钮,防止退出后点击返回按钮再次进入后台页面
$(function() {
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
window.history.pushState('forward', null, '#');
window.history.forward(1);
});
}
window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
window.history.forward(1);
})
window.history:表示window对象的历史记录
window. history.forward() --- 此方法加载历史列表中的下一个 URL,同浏览器中点击向前按钮;
window. history.back() --- 此方法加载历史列表中的前一个 URL,同浏览器中点击后退按钮。