HtmlDocument.OpenNew Method (Boolean)

 

Gets a new HtmlDocument to use with the Write method.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public HtmlDocument OpenNew(
	bool replaceInHistory
)

Parameters

replaceInHistory
Type: System.Boolean

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

Return Value

Type: System.Windows.Forms.HtmlDocument

A new document for writing.

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.

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

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

.NET Framework
Available since 2.0
Return to top
Show: