Thursday, December 15, 2011

Disable Refresh in Webpage Using Javascript (F5 & Ctrl + R)

document.onkeydown = function() {    
    switch (event.keyCode) { 
        case 116 : //F5 button
            event.returnValue = false;
            event.keyCode = 0;
            return false
        case 82 : //R button
            if (event.ctrlKey) { 
                event.returnValue = false
                event.keyCode = 0;  
                return false
            } 
    }
}



Place the above javascript in your page,




If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

No comments:
Write comments