Clear WebBrowser control browsing history

后端 未结 2 964
借酒劲吻你
借酒劲吻你 2021-02-10 09:14

I want to clear WebBrowser control history after WebBrowser completes its browsing.

2条回答
  •  离开以前
    2021-02-10 09:29

    The history state of the System.Windows.Forms.WebBrowse control is internal and cannot be modified directly. All actions are performed via the GoBack and GoForward methods.

    You can prevent your users from going backwards and forwards by setting the CanGoBack and CanGoForward properties to false. You would also want to modify the AllowWebBrowserDrop, WebBrowserShortcutsEnabled and IsWebBroserContextMenuEnabled properties as well.

    Because history is only exposed through these methods, properties and user actions there is no need to clear the internal history state because the user cannot act on it. Note that session history (i.e. the back/forward buttons) is a separate concept from the "browser history" (what you see in the History panel in IE).

    Note that it's possible that WebBrowser instances contained within other programs may write to the Windows user IE history files, however I don't know for certain. If they do I doubt there's anything you can do about that.

提交回复
热议问题