Glen said:
You are referring to something in particular? Maybe the disabling of the
refresh functionality in a web browsers? That is emphatically not
possible. (Hence multiple responses stating as much going uncommented by
others.)
In a function capturing onkeydown, type:
event.keyCode = 0; //or any other number but F5
Apart from the lack of discrimination in attempting to cancel all key
presses instead of just (the many) key sequences that would result in a
refresh action, to the best of my recollection only IE browsers allow
the assignment on values to keyCode events.
event.returnValue = false;
return false;
This works...
You are defining "works" as: works to inhibit only the use of the F5 key
to refresh the page, on javascript enabled default configurations of
Windows IE, but only when key events are passing through the document
(which they don't necessarily have to). The use of such a lax definition
of "works" means that whatever (harmful?) consequences follow from the
user refreshing the page, this script has done little more than reduce
the chances of them happening. So to exactly the extent to which those
consequences are undesirable, this proposal is inadequate.
Normal actions on the part of the client browser such as refreshing a
page, or moving back and forward in the history, or opening another
window showing the same URL (with Ctrl-N on Windows IE) should be
anticipated by the author of a server-side system that is to use a
browser client. They cannot be reliably prevented so instead they need
to be anticipated and accommodated in the design of the server-side
system. Failing to do that would be creating a web application that is
broken by design, and unsurprisingly the normal advice in that case is
to fix the server side.
Richard.