HtmlDocument.Body 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
拿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。