Home  >  Article  >  Web Front-end  >  How to disable browser rollback in JS

How to disable browser rollback in JS

零到壹度
零到壹度Original
2018-03-23 11:18:153441browse

This article mainly shares with you how to prohibit browser rollback in JS, mainly in the form of code. I hope it can help everyone.

//禁止浏览器的回退
$(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);
});

Related recommendations:

How to prevent the browser from returning to the previous page by clicking the back button?

Use js to disable the browser back button

JS tips: disable the browser back button

The above is the detailed content of How to disable browser rollback in JS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn