Disabling refresh key

In browser-based applications, it can be difficult to cater for the user pressing the F5 (refresh) key. Although it is not possible to reliably prevent the user from making the browser refresh, in some circumstances it is possible to prevent accidental pressing of the F5 key. This page demonstrates how to do that. A JavaScript event handler is dynamically added and removed by pressing the buttons below. When the Disable button is pressed, the keyboard event handler is added that attempts to cancel the key's default action.

Note that this is probably a bad idea in any other context than a browser application!

The JavaScript code here is based on code posted by Martin Honnen in this article in newsgroup netscape.mozilla.dom.

I've tested this on a few browsers; it does work with:

It does not work with:

Check HTML - Check CSS - Index