本文介绍了WebBrowser.Navigate 只是...不是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码:
private void goButton_Click(object sender, EventArgs e)
{
web.Navigate(loginURL.Text + "/auth/login");
}
我有浏览器显示,它只是不导航......它不导航等.
I have the browser showing, and it's just not navigating... It doesn't navigate etc.
网址有效.
推荐答案
MSDN 是你的朋友.确保您有http://"前缀并尝试使用 Navigate(Uri url)
重载.
MSDN is your friend. Make sure you have the 'http://' prefix and try using the Navigate(Uri url)
overload.
// Navigates to the given URL if it is valid.
private void Navigate(String address)
{
if (String.IsNullOrEmpty(address))
return;
if (address.Equals("about:blank"))
return;
if (!address.StartsWith("http://") && !address.StartsWith("https://"))
{
address = "http://" + address;
}
try
{
webBrowser.Navigate(new Uri(address));
}
catch (System.UriFormatException)
{
return;
}
}
这篇关于WebBrowser.Navigate 只是...不是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!