此代码无效?
private void web_FBCheck_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if (web_FBCheck.Url.ToString() == ("http://facebook.com/"))
{
MessageBox.Show("Welcome to Facebook");
textBox3.Text = web_FBCheck.Url.ToString();
}
}
或在链接
中使用if (web_FBCheck.Url.ToString() == "http://facebook.com/")
而不使用( )
答案 0 :(得分:1)
我猜是因为你正在处理Navigating
而不是Navigated
,可能是因为网址格式化。你应该做这样的事情:
private void web_FBCheck_Navigating(object sender, WebBrowserNavigatingEventArgs e) {
if(e.Url.Host.ToLower().IndexOf("facebook.com") > -1) {
MessageBox.Show("Welcome to Facebook");
TextBox3.Text = web_FBCheck.Url.ToString();
}
}