检测我的WebBrowser导航到的特定网站

时间:2013-02-06 20:05:13

标签: c# wpf browser

我在WPF应用程序上使用WebBrowser Control,该应用程序打开一个网站,其中包含用于填写和提交的表单。提交后,它会在10秒后重定向到另一个页面,例如www.google.com

有没有办法检测WebBrowser何时打开www.google.com

1 个答案:

答案 0 :(得分:0)

您可以检测WebBrowser何时在webbrowser_LoadCompleted事件中打开您的网站名称,请尝试以下操作:

void webbrowser_LoadCompleted(object sender, NavigationEventArgs e)
{
    mshtml.HTMLDocument doc =( mshtml.HTMLDocument) s.Document;
    if (doc.parentWindow.window.location.host == "www.google.com")
    {
        MessageBox.Show("you navigated to google");
    }
}
相关问题