VB.Net WebBrowser如何取得鼠标点击位置的标签

代码:

    Private Sub Document_MouseDown(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
        Dim P As Point = web.PointToClient(MousePosition)
        Dim he As HtmlElement = web.Document.GetElementFromPoint(P)        
    End Sub

    Private Sub web_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles web.DocumentCompleted
        AddHandler web.Document.MouseDown, New HtmlElementEventHandler(AddressOf Document_MouseDown)        
    End Sub

示例:

testtext

he.id:标签ID,“id1”
he.name:标签name,“name1”
he.innerhtml:标签内容,“testtext
he.innerText:标签文本内容,“texttext”
he.style:标签style中的内容,“width:100px”
he.tagname:标签tagname,“div”

你可能感兴趣的:(.Net)