HtmlDocument.OpenNew(Boolean) Method

Definition

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

public:
 System::Windows::Forms::HtmlDocument ^ OpenNew(bool replaceInHistory);
public 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

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.

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

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

See also