//防止页面后退
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function() {
history.pushState(null, null, document.URL);
});
// 初始化操作
$(document).ready(function() {
// 浏览器后退按钮及鼠标右键回退按钮禁用
// noBack();
// 禁止右键刷新
document.oncontextmenu = function() {
return false;
};
// 禁止浏览器刷新
window.onbeforeunload = function() {
// window.event.returnValue='确认真的要刷新?';
// alert("本系统禁止刷新");
};
});
// 浏览器回退禁止
function noBack () {
// 历史记录栈中记录页数
var numberOfEntries = window.history.length;
if (window.history && window.history.pushState) {
$(window).on('popstate', function() {
// 当点击浏览器的 后退和前进按钮 时才会被触发,
window.history.pushState('forward', null, '');
window.history.forward(1);
});
}
// 新弹出页对应
if (numberOfEntries != 1) {
// 页面间跳转用
window.history.pushState('forward', null, '');
window.history.forward(1);
}
};