The below code is for disabling the back button in browser.
onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload=""
<script type = "text/javascript" >
window.history.forward();
function noBack() {
window.history.forward();
window.onload = window.history.forward(0);
window.onbeforeunload = function () { return "You work will be lost."; };
}
</script>
I can't do it for the forward button.
Try this code in javascript
<script type = 'text/javascript' >
function changeHashOnLoad() {
window.location.href += '#';
setTimeout('changeHashAgain()', '50');
}
function changeHashAgain() {
window.location.href += '1';
}
var storedHash = window.location.hash;
window.setInterval(function () {
if (window.location.hash != storedHash) {
window.location.hash = storedHash;
}
}, 50);
window.onload=changeHashOnLoad;
</script>
Alternate method
<SCRIPT type='text/javascript'>
window.history.forward();
function noBack() {window.history.forward(); }
window.onload=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack()}
window.onunload=function(){void(0)}
</SCRIPT>
Hope this helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.