How do I disable the F5 refresh on the browser?

前端 未结 4 706
栀梦
栀梦 2021-01-12 18:12

Preferably using JavaScript but would like to hear other ways too

4条回答
  •  死守一世寂寞
    2021-01-12 18:38

    Actually, you can.. This little routine fixed it all for me..

    I needed the other shortcuts, but not F5.

    Private Sub WebBrowser1_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles WebBrowser1.PreviewKeyDown
        If e.KeyCode = Keys.F5 Then WebBrowser1.WebBrowserShortcutsEnabled = False Else WebBrowser1.WebBrowserShortcutsEnabled = True
    End Sub
    

    Quick and dirty, but it works. Now, I can still use the Ctrl-B, I and U for editing, but I don't have to worry about refresh killing it!!

    Enjoy!

提交回复
热议问题