Home  >  Article  >  Backend Development  >  C# WinForm WebBrowser set to edit mode sample code

C# WinForm WebBrowser set to edit mode sample code

黄舟
黄舟Original
2017-03-11 13:09:551453browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn