Click here to Skip to main content
15,394,560 members
Articles / Web Development / ASP.NET
Alternative
Tip/Trick
Posted 7 Feb 2012

Stats

9.8K views
1 bookmarked

How to prevent Re-Post action caused by pressing browser's Refresh button

Rate me:
Please Sign up or sign in to vote.
2.00/5 (2 votes)
7 Feb 2012CPOL
Could you not achieve the same thing with javascript?if (document.all){ document.onkeydown = function () { var key_f5 = 116; if (key_f5==event.keyCode){ event.keyCode=0; alert ("Sorry! You can not refresh this page!"); ...
Could you not achieve the same thing with javascript?

JavaScript
if (document.all){
    document.onkeydown = function ()
    {
        var key_f5 = 116;
        if (key_f5==event.keyCode){
            event.keyCode=0;
            alert ("Sorry! You can not refresh this page!");
            return false;
        }
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Member 4236865
United Kingdom United Kingdom
No Biography provided

Comments and Discussions

 
GeneralReason for my vote of 2 There are other ways to refresh the ... Pin
John Brett7-Feb-12 22:16
MemberJohn Brett7-Feb-12 22:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.