Reputation: 318
I have a JS Application that runs some kind of things.
I want to disable ctrl+r and f5 so I don't get a browser refresh.
I disable ctrl+r completely and replace the disabled f5 refresh with my own handling (ajax, calls on RAP,DB, etc.)
Both mechanics work fine on FF, Chrome, Opera and Safari.
Which means I can spam-bot key combinations and everything works perfect.
In IE 9 though, when I press f5 to fast sequentially it does do a regular refresh, which means to me IE 9 takes to long for the operation and its no ready for the next keydown function.
$(document).keydown(function (event) {
if ((event.ctrlKey == true && (event.keyCode == 17 || event.keyCode == 82)) || (event.keyCode == 116)) {
event.preventDefault();
if (event.keyCode == 116) {
// Here is the own Reload Logic which contains calls on DB and Server.
}
if ($.browser.msie) {
window.event.stopPropagation();
window.event.keyCode = 0;
window.event.returnValue = false;
window.event.cancelBubble = true;
}
}
});
Is it possible to somehow manage this to fast pressing f5 (so it keeps being disabled) in IE 9?
Upvotes: 0
Views: 1634
Reputation:
You can only prevent F5 with WebBrowserShortcutsEnabled, but you will kill all other shortcuts the browser has on that page. You should try to block the process of people leaving the webpage. That would be more productive in what you want to achieve.
window.onbeforeunload = function() {
return "You are trying to leave.";
}
This should not be used as a safety measure tho, like for students taking web-tests/exams. But if it's just to prevent accidental refresh, this should do the trick.
Upvotes: 4