开发者

Disable F5 in WebBrowser [duplicate]

开发者 https://www.devze.com 2023-01-21 14:17 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicates: Disable browser's back button
This question already has answers here: Closed 12 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消