VB.net 如何在WebBrowser中插入新的内容

xiaoxiao2021-02-28  106

在Body中追加  代码:

Private Sub cmdAddPic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddPic.Click Dim el As HtmlElement = web.Document.CreateElement("div") el.InnerHtml = "<a href=''>test</a>" el.Id = "id1" web.Document.Body.AppendChild(el) el = Nothing End Sub

在指定的标签里追加 代码

Private Sub cmdAddPic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddPic.Click el = web.Document.CreateElement("div") el.InnerHtml = "test2" el.Id = "id2" web.Document.GetElementById("id1").AppendChild(el) el = Nothing End Sub

其实就是先通过GetElementById找到标签,然后再追加到进去

转载请注明原文地址: https://www.6miu.com/read-22252.html

最新回复(0)