Cancel User f5 keystroke

For all the people who asked if it is possible to stop users F5 refreshing the page. here is the solution.
Brian R. James wrote a greate article wich sums to this javascript function

function onkeydown_handler() { switch (event.keyCode) { case 116 : //F5 event.returnValue = false; event.keyCode = 0; break; } }
and you have to attach the event to the function you have just created
document.attachEvent("onkeydown", onkeydown_handler); or if (document.all) { document.onkeydown = onkeydown_handler(); }
i hope this will help all the seakers of the how to disable refresh button when a user clicks it.
you can allso check to see if the Ctrl/Alt/Shift key was held during the event by adding this statement
if (event.ctrlKey) {
after the case.

Speak Your Mind

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.