Write a program to download files in batches. The HTML page to be analyzed requires logging in to access, but the downloaded related pages do not require logging in to access, so I was lazy and set the WebBrowser to edit in the program. mode, just copy the content to be analyzed from the logged-in browser window.
Setting method:
private void mainForm_Load(object sender, EventArgs e) { this.webBrowser1.Navigate("about:blank"); if (this.webBrowser1.Document != null) { mshtml.IHTMLDocument2 doc = this.webBrowser1.Document.DomDocument as mshtml.IHTMLDocument2; if (doc != null) { doc.designMode = "on"; } } }
Open "about:blank" by default, otherwise "webBrowser1.Document == null";
doc.designMode = "on" is the editing mode, doc.designMode = "off" is the browsing mode;
Need to add a reference:
Only used here: MSHTML
## ======================Document information========================== =
The above is the detailed content of C# WinForm WebBrowser set to edit mode sample code. For more information, please follow other related articles on the PHP Chinese website!