HtmlDocument.OpenNew(Boolean) Method

Definition

Gets a new HtmlDocument to use with the Write(String) method.

C#
public System.Windows.Forms.HtmlDocument OpenNew(bool replaceInHistory);
C#
public System.Windows.Forms.HtmlDocument? OpenNew(bool replaceInHistory);

Parameters

replaceInHistory
Boolean

Whether the new window's navigation should replace the previous element in the navigation history of the DOM.

Returns

A new document for writing.

Examples

The following code example prepares the DOM for writing and writes a new document using the Write method.

C#
private void WriteNewDocument()
{
    if (webBrowser1.Document != null)
    {
        HtmlDocument doc = webBrowser1.Document.OpenNew(true);
        doc.Write("<HTML><BODY>This is a new HTML document.</BODY></HTML>");
    }
}

Remarks

OpenNew will clear the previous loaded document, including any associated state, such as variables. It will not cause navigation events in WebBrowser to be raised.

OpenNew always creates a new document in the current window. To open a document in a new window, use the Open method on the HtmlWindow class.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also