Disable F5 Key Using jQuery


Disable F5 Key Using jQuery

Disable Browser Refresh Button using JavaScript

In this blog post I will share a tip to prevent user refreshing the browser using keyboard f5 function key using jQuery. It works well with IE8, IE9, Mozilla14 and Chrome26 browser as well. Find the javascript code snippet below :-

disable f5 key using jquery,javascript f5 refresh event,javascript prevent page refresh on submit,javascript disable meta refresh,disable browser refresh button using javascript,how to disable refresh button of browser using jquery
javascript disable meta refresh

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>How to Block Refresh Key (F5) in JavaScript</title>

    <script type="text/javascript">

        var version = navigator.appVersion;

        function showKeyCode(e) {
            var keycode = (window.event) ? event.keyCode : e.keyCode;

            if ((version.indexOf('MSIE') != -1)) {
                if (keycode == 116) {
                    event.keyCode = 0;
                    event.returnValue = false;
                    return false;
            else {
                if (keycode == 116) {
                    return false;


<body onload="JavaScript:document.body.focus();" onkeydown="return showKeyCode(event)">
    <form id="form1" runat="server">
        Demo ..
Disable F5 Key Using jQuery Reviewed by Ravi Kumar on 2:32 PM Rating: 5


All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form


Email *

Message *

Powered by Blogger.