[英]webBrowser1 open webpage
How do I open the webpage in webBrowser1? 如何在webBrowser1中打开网页?
I added new webBrowser component into new window, when I added the button this is the code on this button: 我将新的webBrowser组件添加到新窗口中,当我添加按钮时,这是该按钮上的代码:
private void button1_Click(object sender, EventArgs e)
{
string URL = @"http://www.site.com/search?=N";
this.webBrowser1.Url = new Uri(URL);
this.webBrowser1.Navigate("URL");
this.webBrowser1.Refresh();
}
But it does not work - no errors reported, but webBrowser1 does not show any data after the button is pressed. 但这不起作用-没有报告错误,但是在按下按钮后,webBrowser1不显示任何数据。
Instead of: 代替:
this.webBrowser1.Navigate("URL");
try: 尝试:
this.webBrowser1.Navigate(URL);
This way instead of navigating to the site "URL"
(which obviously doesn't exist) you navigate to the site that the URL variable is pointing to (which is http://www.site.com/search?=N
). 这样,您无需导航到站点
"URL"
(显然不存在),而是导航到URL变量指向的站点(即http://www.site.com/search?=N
)。
尽量不要将URL
放在引号中:
this.webBrowser1.Navigate(URL);
您是否尝试过:
this.webBrowser1.Navigate(URL);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.