Share via


HtmlDocument.OpenNew(Boolean) 方法

定義

取得要與 Write(String) 方法搭配使用的新 HtmlDocument

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

參數

replaceInHistory
Boolean

新視窗的巡覽是否應該取代 DOM 巡覽歷程記錄中的先前項目。

傳回

要撰寫的新文件。

範例

下列程式碼範例會準備 DOM 以使用 Write 方法來撰寫和寫入新檔。

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 將會清除先前載入的檔,包括任何相關聯的狀態,例如變數。 這不會引發 中的 WebBrowser 導覽事件。

OpenNew 一律會在目前視窗中建立新的檔。 若要在新視窗中開啟檔,請使用 Open 類別上的 HtmlWindow 方法。

適用於

另請參閱