Reputation: 8241
Essentially, in our system, our users enter reports and they find all manners of ways to accidentally lose their work on them so we have been locking down everything that they can press that might make them lose data. F5, CRTL + R, CTRL + W and Backspace are all disabled; all bars in IE are hidden and there is a confirmation dialog on the close button.
I have not had any luck in disabling ALT + F4, ALT + ←, ALT + →
I have tried disabling them with javascript. However my method is not working.
if (window.event.altKey) {
if (window.event.keyCode == 115) {
window.event.cancelBubble = true;
window.event.returnValue = false;
window.event.keyCode = 0;
window.status = "Alt + F4 is disabled on all popups";
return false;
}
}
I'm thinking I may require more drastic methods.
In this answer here, he suggests this may be possible with shdocvw.dll but I'm not sure what that would entail.
Is there a means to disable the Alt + X combination or perhaps work around I can exploit for them?
Upvotes: 0
Views: 1479
Reputation: 30311
No, you can't disable those combinations - and for good security reasons (otherwise any webpage could potentially hijack your computer...).
Your best bets are (in decreasing order of functionality):
Upvotes: 1
Reputation: 46647
You shouldn't mess with default browser behavior. If you're worried about users accidently closing the window, just use the onbeforeunload
event:
window.onbeforeunload = function () {
return 'You will lose all unsaved changes.';
};
http://jsfiddle.net/jbabey/rPLWd/
Upvotes: 1