如果webbrowser导航到某个URL,那么这样做? VB

时间:2012-02-11 10:49:08

标签: vb.net url if-statement checkbox browser

我到处寻找这个!我需要做的就是:

If the webbrowser's url = "http://www.example.com" then 
   CheckBox1.CheckState = CheckState.Checked 
end if

感谢。

....后来我找到了答案: 我终于找到了答案:

If WebBrowser1.Url.ToString = "http://www.example.com" Then
        do something
End If

这必须在webbrowser文档中完成sub:

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

    End Sub

总而言之,答案是:

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As   System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted   

   If WebBrowser1.Url.ToString = "http://www.example.com" Then
        do something
   End If

end sub

1 个答案:

答案 0 :(得分:0)

您可以使用DocumentCompleted事件。

查看同一页面中给出的示例。