HtmlDocument.Body 屬性

定義

HtmlElement到標籤。BODY

public:
 property System::Windows::Forms::HtmlElement ^ Body { System::Windows::Forms::HtmlElement ^ get(); };
public System.Windows.Forms.HtmlElement Body { get; }
public System.Windows.Forms.HtmlElement? Body { get; }
member this.Body : System.Windows.Forms.HtmlElement
Public ReadOnly Property Body As HtmlElement

屬性值

標籤的HtmlElementBODY物件。

範例

以下程式碼範例會建立一個新 DIV 元素,並利用該 AppendChild 方法將其附加到文件底部。

private void AppendText(String text)
{
    if (webBrowser1.Document != null)
    {
        HtmlDocument doc = webBrowser1.Document;
        HtmlElement textElem = doc.CreateElement("DIV");
        textElem.InnerText = text;
        doc.Body.AppendChild(textElem);
    }
}
Private Sub AppendText(ByVal Text As String)
    If (WebBrowser1.Document IsNot Nothing) Then
        With WebBrowser1.Document
            Dim TextElem As HtmlElement = .CreateElement("DIV")
            TextElem.InnerText = Text
            .Body.AppendChild(TextElem)
        End With
    End If
End Sub

備註

HTML 文件分為兩大部分:

  • HEAD,包含文件標題、任何文件的元資料及 SCRIPT 元素。

  • BODY,包含文件螢幕呈現的所有元素。

在 上Head沒有等價HtmlDocument性質。 要得到元素, HEAD 請使用 GetElementsByTagName

適用於

另請參閱