0

Browser reload icon functionality should be disabled for a particular page.Even though if it reloads also,the page content should not change.

Mounika R
  • 1
  • 1
  • 2

1 Answers1

2

You can disable refresh by using the following code

 $(document).on("keydown", function (e) {
        if (e.key == "F5" || e.key == "F11" || 
            (e.ctrlKey == true && (e.key == 'r' || e.key == 'R')) || 
            e.keyCode == 116 || e.keyCode == 82) {

                   e.preventDefault();
        }
    });

Even after this the user can refresh using browser refresh button. If so we can just give a confirmation message using

window.onbeforeunload = function() {
        return "Leave this page ?";
    }
Sandeep P Pillai
  • 753
  • 1
  • 4
  • 22