Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1521 How can I cancel the users F5 request to refresh the page in Internet Explorer?

You are here: irt.org | FAQ | JavaScript | Event | Q1521 [ previous next ]

Do it by redirecting the keyboard action on another keycode that you can control (backspace in this example):

function cancelRefresh() {
  // keycode for F5 function
  if (window.event && window.event.keyCode == 116) {
    window.event.keyCode = 8;
  }
  // keycode for backspace
  if (window.event && window.event.keyCode == 8) {
    // try to cancel the backspace
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    return false;
  }
}

This function is called on the onKeyDown event and it seems to work!

Feedback on 'Q1521 How can I cancel the users F5 request to refresh the page in Internet Explorer?'

©2018 Martin Webb