How do I disable the F5 refresh on the browser?

懵懂的女人 提交于 2019-12-01 02:41:06

问题


Preferably using JavaScript but would like to hear other ways too


回答1:


This will disable F5, but not the actual refresh function:

document.onkeydown = function (e) {
  if (e.keyCode === 116) {
    return false;
  }
};

On Chrome/XP, at least.




回答2:


  1. Write a series of browser extensions which remove refresh functionality.
  2. Require in your Terms of Use that your users install (and use) your extension.
  3. Prosecute for non-compliance.
  4. Profit! (?)



回答3:


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!




回答4:


You can't disable refresh.



来源:https://stackoverflow.com/questions/2918061/how-do-i-disable-the-f5-refresh-on-the-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!