HtmlDocument.OpenNew(Boolean) HtmlDocument.OpenNew(Boolean) HtmlDocument.OpenNew(Boolean) HtmlDocument.OpenNew(Boolean) Method


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

 System::Windows::Forms::HtmlDocument ^ OpenNew(bool replaceInHistory);
public System.Windows.Forms.HtmlDocument OpenNew (bool replaceInHistory);
member this.OpenNew : bool -> System.Windows.Forms.HtmlDocument
Public Function OpenNew (replaceInHistory As Boolean) As HtmlDocument


Boolean Boolean Boolean Boolean

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


A new document for writing.


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>");
Private Sub WriteNewDocument()
    If (WebBrowser1.Document IsNot Nothing) Then
        Dim doc As HtmlDocument = WebBrowser1.Document.OpenNew(True)
        doc.Write("<HTML><BODY>This is a new HTML document.</BODY></HTML>")
    End If
End Sub


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

See also