开发者

implement button click in html

I have been trying to execute a button event in html page that displays additional content on the web page. I am getting a null reference error when using the getelementbyid and not sure how to change this. Here is the html reference I need to engage:

<div class="button" style="float:none;width:180px;margin:20px auto 30px;"><a href="#" id="more" style="width:178px">Show more ▼</a></div>

        </div>

and here is my code:

                Dim wb As New WebBrowser
                wb.Navigate(fromUrl)


                While wb.ReadyState <> WebBrowserReadyState.Complete
                    Application.DoEvents()
                End While
                Debug.Write(wb.DocumentText)
                Dim htmlElements As HtmlElementCollection = wb.Document.GetElementsByTagName("<a")
     开发者_开发技巧           If Not wb.Document Is Nothing Then
                    Try
                        If wb.DocumentText.Contains("more") Then
                            If wb.Document.GetElementById("more").GetAttribute("href") Then
                                wb.Document.GetElementById("more").InvokeMember("#")
                            End If
                        End If
                    Catch ex As Exception
                        MessageBox.Show(ex.Message.ToString)
                    End Try
                End If

I appreciate any ideas.


Don't put a "<" in front of the tag name "a".

use

wb.Document.GetElementsByTagName("a")

instead of

wb.Document.GetElementsByTagName("<a")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜