Example: Block browser F5 refresh and refresh iframe instead
// Capture F5 event
$("body").keydown(function(e){
var ev = window.event || e;
var code = ev.keyCode || ev.which;
if (code==116) {
// Prevent the default F5 event
if(ev.preventDefault) {
ev.preventDefault( );
}else {
ev.keyCode=0;
ev.returnValue=false;
}
// Call the refresh function
Refresh();
}
});
//Refresh the current frame
function Refresh() {
document.getElementById('right-main-frame').contentWindow.location.reload();//Support IE
}
Other keyboard events:
code==13; //Enter event
code==37; //Left arrow key
code==38;//Up arrow key
code==39;//Right arrow key
code==40;//Down arrow key
code ==8;//Backspace delete key
code==116;//F5 refresh key
code==78;//Ctrl n
code==121;//Shift F10
code==122;//F12