System.__ComObject is returned when I use getAttribute

后端 未结 2 1605
北荒
北荒 2020-12-22 06:38

I am running this code:

HtmlElement.GetAttribute(\"onClick\")

To try and get access to the onClick attribute of that element, but all this

2条回答
  •  太阳男子
    2020-12-22 07:06

    Sample code

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("http://stackoverflow.com/questions/9707869/system-comobject-is-returned-when-i-use-getattribute")
    End Sub
    
    Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        Dim a As HtmlElement = WebBrowser1.Document.GetElementById("portalLink").FirstChild
        MsgBox(a.DomElement.attributes("onclick").value.ToString)
    End Sub
    

提交回复
热议问题