Possible Duplicates:
Disable browser's back button How do I disable the F5 refresh on the browser?
Hi,
I created an a开发者_JS百科pplication in C# that will download data from the internet (and this is done one time only) and put it in a webbrowser and this data should be static. I want to know if there is a way to disable the F5 key from doing a refresh?
I tried injecting javascript to disable F5 but it will still refresh the webbrowser.
You cannot disable F5 (or other browser shortcut keys) via JavaScript.
Setting the WebBrowserShortcutsEnabled
property of the WebBrowser
control to false
should accomplish what you're trying to do.
call this function on the onKeyDown event
document.onkeydown = function(e) {
// keycode for F5 function
if (e.keyCode === 116) {
return false;
}
// keycode for backspace
if (e.keyCode === 8) {
// try to cancel the backspace
return false;
}
};
This will prevent from F5 reload and backspace back.
精彩评论