Example code for C # WinForm WebBrowser set to edit mode

Source: Internet
Author: User
Write a program bulk download files, to analyze the HTML page is required to login to access, and download the relevant page is not required to login access, so steal a lazy, the program to set WebBrowser to edit mode, This allows you to copy the content you want to analyze from the browser window that is already logged in.

Setup 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";}}        }

"About:blank" is turned on by default, otherwise "webbrowser1.document = = null";

Doc.designmode = "On" is the edit mode, Doc.designmode = "Off" is the browse mode;

You need to add a reference:

It's only used here: MSHTML

====================== Document Information ===========================

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.