Webbrowser1.scripterrorssuppressed = true; // error script disabling prompt
Webbrowser1.iswebbrowsercontextmenuenabled = false; // disable the context menu
Webbrowser1.webbrowsershortcutsenabled = false; // disable the shortcut key
When using webbrowser for UI, we sometimes do not want the link to be clicked by users, do not want to pop up an annoying Script Error prompt box, and do not want users to right-click the IE menu, to do this, it is actually very easy...
Error script disabling prompt
Set scripterrorssuppressed of the webbrowser control to true.
Disable right-click menu
Set iswebbrowsercontextmenuenabled of webbrowser to false
Disable shortcuts
Set webbrowsershortcutsenabled of webbrowser to false
Disable hyperlink
There are two types of hyperlinks: Direct redirection of the current window and opening of the new window.
Of course, direct window redirection:
Set allownavigation of webbrowser to false
Open in a new window:
To disable the opening of a new window, you must handle the newwindow event of webbrowser.
Private void webbrowser1_newwindow (Object sender, canceleventargs E)
{
E. Cancel = true;
}
After the above work is done, it is basically finished. The last point should be noted, that is, drag-and-drop.
Remember to set allowwebbrowserdrop of webbrowser to false.