HtmlDocument.Body Proprietà

Definizione

Ottiene l'oggetto HtmlElement per il BODY tag.

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

Valore della proprietà

Oggetto HtmlElement per il BODY tag.

Esempio

Nell'esempio di codice seguente viene creato un nuovo DIV elemento e lo aggiunge alla parte inferiore del documento usando il AppendChild metodo .

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

Commenti

Un documento HTML è suddiviso in due sezioni principali:

  • HEAD, che contiene il titolo del documento, tutti i metadati del documento e SCRIPT gli elementi.

  • BODY, che contiene tutti gli elementi coinvolti nell'aspetto sullo schermo del documento.

Non esiste alcuna proprietà equivalente Head in HtmlDocument. Per ottenere l'elemento HEAD , usare GetElementsByTagName.

Si applica a

Vedi anche