top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

disable all refresh events using javascript/jquery

+5 votes
8,894 views

I need disable all refresh events

Example.

  1. F5,
  2. Mouse right click option (refresh/reload),
  3. CTRL+R,
  4. Menu bar -> view -> refresh and
  5. URL refresh/reload button

How to disable these all events by using javascript...

Advance thanks....

posted Dec 7, 2015 by Shivaranjini

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Block F5 Key In IE & Mozilla</title>


    <script language="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;
                }
            }
        }


    </script>


</head>
<body onload="JavaScript:document.body.focus();" onkeydown="return showKeyCode(event)">
</body>
</html>

2)http://codingresource.blogspot.in/2010/04/disable-refresh-in-webpage-using.html

answer Dec 9, 2015 by Manikandan J
Hi Manikandan,
This Code is worked only in F5.
But I need the below all events are also disable.
Mouse right click option (refresh/reload),
CTRL+R,
Menu bar -> view -> refresh and
URL refresh/reload button
How to disable these all events by using javascript...
If you are correct means pls explain it. Its not disable in all events.
Thank You
regards,
K. Ranjini
Yes Ranjini that answer was not yet complete only for F5, i will check and update the code.
Similar Questions
0 votes

I tried the following code.Both onpaste() and Oncopy() will trigger when user trying to copy or paste.

But my problem is while copying something window.getSelection() not working.

Window.getSelection() is used to get the selected data.

I mean before copying something user need to select some values.So,using this window.getselection() we will get the value what they are selected.

Here, my problem is window.getselection() will work in oncopy but not working in onpaste.

Check the below examples and help me to solve the problem.

Also ,is there any alternative method also please let me know.I also tried window.clipboardData.But not getting the solution for this.

<!doctype html>
<html>
<head>
<style>
    textarea {
        width:500px;
        height:200px;
        border:2px solid #999;
    }
</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    <script type="text/javascript">

        function OnPaste () {                                                                       
            var selection = window.getSelection();          
            alert(selection.toString());            
        }                                       
        function OnCopy() {         
            var selection = window.getSelection();
            alert(selection.toString());
         }

// Call the OnCopy function while user trying to copy 
document.oncopy = OnCopy;

// Call the OnPaste function while user trying to Paste
document.onpaste = OnPaste;
 </script>

</head>
<body>
    Select some text, copy it to the clipboard and try to paste it to the following fields:
    <br /><br />
    <textarea size="40" value="Copy and Paste operation is enabled">
0 votes

Also,tell me what are the types of framework are there ?

+3 votes

I am trying to control input field using jQuery previously I had only numbers and could use $(this).autoNumeric(), now I have come around where it is required to change the input field in form of 'Numbers dash Numbers'.
i.e:- 1.343-45.643

Is there anything similar to autoNumeric which can do my work apart from writing my own regex and jquery method.

...