This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16760|Reply: 0

[WinForm] How to disable error prompts when webBrowser displays html content in C# Winform

[Copy link]
Posted on 7/8/2017 11:33:19 PM | | |

In WinForm, there is a control that can display HTML content, which is the webbrowser, and set its DocumenText property to HTML content.

When using WebBrowser for UI, we sometimes don't want the link in it to be clicked by the user, let alone the annoying script error prompt box popping up, and we don't want the user to be able to click the right-click IE menu.
Disable error script hint: Set the WebBrowser control's scrip{filter}tErrorsSuppressed to true
Disable Right-Click Menu: Set WebBrowser's IsWebBrowserContextMenuEnabled to false
Disable shortcuts: Set WebBrowser's WebBrowserShortcutsEnabled to false
Disable hyperlinks : There are two types of hyperlinks, one is direct to the current window, and the other is to open in a new window  
Of course the window turns directly: Set the WebBrowser's AllowNavigation to false
Disabling new window openings requires handling the WebBrowser's NewWindow event


After completing the above work, it is basically complete, and there is one last point to pay attention to, which is Drag-And-Drop. Remember to set the WebBrowser's AllowWebBrowserDrop to false






Previous:SignalR for websocket communication (3)
Next:.net/C# webBrowser control disables pop-up solutions like alert, confirm, etc
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com