C# winform 中的webBrowser1的网站打开后 怎么让弹窗在webBrowser2里面显示 而不是在IE浏览器显示 !
2个回答
展开全部
/// <summary>
/// 单击网页菜单时两边都会变
/// 其它的可以直接显示在webBrowser2
/// </summary>
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
this.webBrowser1.Url = new System.Uri("http://www.sina.com.cn", System.UriKind.Absolute);
this.webBrowser1.NewWindow += new System.ComponentModel.CancelEventHandler(this.web_NewWindow);
this.webBrowser1.Navigating +=new WebBrowserNavigatingEventHandler(webBrowser1_Navigating);
}
string newURL;
private void web_NewWindow(object sender, CancelEventArgs e)
{
newURL = webBrowser1.StatusText.ToString();
// newURL = webBrowser1.Document.ActiveElement.GetAttribute("href");
Uri newurl = new Uri(newURL);
this.webBrowser2.Url = newurl;
this.webBrowser2.Refresh();
e.Cancel = true;
}
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
newURL = webBrowser1.StatusText.ToString();
// newURL = webBrowser1.Document.ActiveElement.GetAttribute("href");
Uri newurl = new Uri(newURL);
this.webBrowser2.Url = newurl;
this.webBrowser2.Refresh();
}
}
/// 单击网页菜单时两边都会变
/// 其它的可以直接显示在webBrowser2
/// </summary>
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
this.webBrowser1.Url = new System.Uri("http://www.sina.com.cn", System.UriKind.Absolute);
this.webBrowser1.NewWindow += new System.ComponentModel.CancelEventHandler(this.web_NewWindow);
this.webBrowser1.Navigating +=new WebBrowserNavigatingEventHandler(webBrowser1_Navigating);
}
string newURL;
private void web_NewWindow(object sender, CancelEventArgs e)
{
newURL = webBrowser1.StatusText.ToString();
// newURL = webBrowser1.Document.ActiveElement.GetAttribute("href");
Uri newurl = new Uri(newURL);
this.webBrowser2.Url = newurl;
this.webBrowser2.Refresh();
e.Cancel = true;
}
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
newURL = webBrowser1.StatusText.ToString();
// newURL = webBrowser1.Document.ActiveElement.GetAttribute("href");
Uri newurl = new Uri(newURL);
this.webBrowser2.Url = newurl;
this.webBrowser2.Refresh();
}
}
展开全部
webBrowserContext.Navigate("http://www.baidu.com");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |