下面是我做的一个简单浏览器,输入网址之后老是跳转到默认浏览器,请高手帮我看下
private void GoBtn_Click(object sender, EventArgs e)
{
System.Object nullObject=0;
string str=" ";
System.Object nullObjStr =str;
Cursor.Current=Cursors.WaitCursor;
axWebBrowser1 .Navigate (textBox1 .Text ,ref nullObject ,ref nullObjStr,ref nullObjStr,ref nullObjStr);
Cursor.Current =Cursors.Default;
}
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
{
string strurl = webBrowser1.Document.ActiveElement.GetAttribute("href");
if (!strurl.Contains("://"))
strurl = "http://" + strurl;
this.webBrowser1.Url = new System.Uri(strurl, System.UriKind.Absolute);
e.Cancel = true;
}
} private void toolBar1_ButtonClick(object sender,System .Windows .Forms . ToolBarButtonClickEventArgs e)
{
if (e.Button == toolBarButton1)
axWebBrowser1.GoBack();
if (e.Button == toolBarButton2)
axWebBrowser1.GoForward();
if (e.Button == toolBarButton3)
axWebBrowser1.Refresh();
if (e.Button == toolBarButton4)
axWebBrowser1.GoHome();
if (e.Button == toolBarButton5)
axWebBrowser1.Stop();
}
private void GoBtn_Click(object sender, EventArgs e)
{
System.Object nullObject=0;
string str=" ";
System.Object nullObjStr =str;
Cursor.Current=Cursors.WaitCursor;
axWebBrowser1 .Navigate (textBox1 .Text ,ref nullObject ,ref nullObjStr,ref nullObjStr,ref nullObjStr);
Cursor.Current =Cursors.Default;
}
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
{
string strurl = webBrowser1.Document.ActiveElement.GetAttribute("href");
if (!strurl.Contains("://"))
strurl = "http://" + strurl;
this.webBrowser1.Url = new System.Uri(strurl, System.UriKind.Absolute);
e.Cancel = true;
}
} private void toolBar1_ButtonClick(object sender,System .Windows .Forms . ToolBarButtonClickEventArgs e)
{
if (e.Button == toolBarButton1)
axWebBrowser1.GoBack();
if (e.Button == toolBarButton2)
axWebBrowser1.GoForward();
if (e.Button == toolBarButton3)
axWebBrowser1.Refresh();
if (e.Button == toolBarButton4)
axWebBrowser1.GoHome();
if (e.Button == toolBarButton5)
axWebBrowser1.Stop();
}
axWebBrowser.RegisterAsBrowser=true;在webBrowser1_NewWindow事件中增加上面那一句,试试看就知道了
还有com组件的浏览器和.net类库自带的WebBrowser是什么啊,我是新手,不太懂,再帮我分析下吧