[英]Enable forward button while disabling browser back button
I disabled browser back button using the following code on load of page 我在页面加载时使用以下代码禁用了浏览器后退按钮
history.pushState(null, null, location.href);
window.onpopstate = function () {
history.go(1);
};
Code is working fine.I am not able to proceed for previous pages. 代码工作正常。我无法继续前一页。 But forward button is also disabled.
但是前进按钮也被禁用。 I have to enable forward button on the page.
我必须启用页面上的前进按钮。
You are forcing to update url manually by using history.pushState . 您被迫使用history.pushState手动更新url。 If you use history.pushState , it clears forward state's history.
如果使用history.pushState ,它将清除转发状态的历史记录。
Hence window.history.forward()
returns undefined. 因此
window.history.forward()
返回未定义。 So you cannot go to forward direction. 因此,您无法前进。
Kindly use warning instead of disabling back button, 请使用警告而不是禁用后退按钮,
window.onbeforeunload = function() {
return "some text"
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.