I’m trying to avoid users to use the back button, it was so far so good, until I try to get the context menu, right clicking over Chrome’s title bar I’ve seen other pages that doesn´t have the same options I do.
I used this code:
< script type="text/javascript">
function disableBackButton() {
window.history.forward(1);
}
setTimeout("disableBackButton()", 0);
window.oncontextmenu = function() { return false }
</ script>
< script type="text/javascript">
if (typeof window.event != 'undefined')
document.onkeydown = function() {
if (event.srcElement.tagName.toUpperCase() != 'INPUT')
return (event.keyCode != 8);
}
else
document.onkeypress = function(e) {
if (e.target.nodeName.toUpperCase() != 'INPUT')
return false;
}
</ script>
< script type="text/javascript">
document.onkeydown = chkEvent
var formInUse = false;
function chkEvent(e) {
var keycode;
if (window.event) keycode = window.event.keyCode; //*** for IE ***//
else if (e) keycode = e.which; //*** for Firefox ***//
if (keycode == 8) {
return false;
}
}
</ script>
< body onload="disableBackButton();" >
It seems to me that there is not much to do and that’s OS territory, but worth a try if someone knows about this
Kind Regards
George
You absolutely CANNOT and MUST NOT be allowed to do anything outside your webpage sandbox. Even if you accidentally find a way in some browser to do that, do not rely on it, as it is will be viewed as huge security risk and promptly patched or reduced to some hidden-flag activated kludge by developers. Just drop the idea as it stands completely against what browser’s sandboxed environment tries to accomplish, so it won’t work in any public project.