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

前端之家收集整理的这篇文章主要介绍了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

示例:<div id="id1" name="name1" style="width:100px">test<span>text</span></div> he.id:标签ID,“id1” he.name:标签name,“name1” he.innerhtml:标签内容,“test<span>text</span>” he.innerText:标签文本内容,“texttext” he.style:标签style中的内容,“width:100px” he.tagname:标签tagname,“div”

猜你在找的VB相关文章