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

How to disable browser rollback in JS

零到壹度
Release: 2018-03-23 11:18:15
Original
3514 people have browsed it

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);
});
Copy after login

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!

Related labels:
Statement of this Website
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template