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,其中包含檔畫面上外觀所涉及的所有元素。

HtmlDocument 沒有對等 Head 的屬性。 若要取得 HEAD 專案,請使用 GetElementsByTagName

適用於

另請參閱