I am working on a project where the user should not be allowed to refresh the page using any of the following techniques:
Refresh, F5, CTRL + F5, CTRL + r... etc.
I am working on a project where the user should not be allowed to refresh the page using any of the following techniques:
Refresh, F5, CTRL + F5, CTRL + r... etc.
document.addEventListener('DOMContentLoaded', function (e) {
document.body.addEventListener('keydown', function (e) {
if (e.keyCode == 116) {
e.preventDefault();
}
}, false);
}, false);
Its nearly impossible to do such thing, you can prompt user from getting refreshed,
var confirmOnPageExit = function (e) {
// If we haven't been passed the event get the window.event
e = e || window.event;
var message = 'Any text will block the navigation and display a prompt';
// For IE6-8 and Firefox prior to version 4
if (e) {
e.returnValue = message;
}
// For Chrome, Safari, IE8+ and Opera 12+
return message;
};
window.onbeforeunload = confirmOnPageExit;