C# WinForm WebBrowser set to edit mode sample code

黄舟
Release: 2017-03-11 13:09:55
Original
1460 people have browsed it

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";
                }
            }
        }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!