clock  Mon - Sun 8.00 AM - 8.00 PM
fb
instagram
play store
pinterest

How To Disable F5 Button Using jQuery

writter  Sumit Dey Sarkar
Date  25 Aug 2022
Language  JQuery
How To Disable F5 Button Using jQuery

How To Disable F5 Button Using jQuery

In this article we will learn how to disable F5 button using jQuery.

Sometime we don't want to refresh web browser using F5 button, then we need to disable F5 button.

Here we use keydown event of jquery and use f5 key code 116 to disable F5 button.

How to disable F5 button using jQuery

<!DOCTYPE html>
<html>

<head>
  <title>How to disable F5 button using jQuery</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
</head>

<body>

  <h1 style="font-size:20px">How to disable F5 button using jQuery</h1>

  <script>
    $(document).ready(function () {
      $(window).keydown(function (event) {
        if (event.keyCode == 116) {
          event.preventDefault();
          return false;
        }
      });
    });
  </script>

</body>

</html>