如何只在自己的窗体中用vb webbrowser打开网页
2个回答
展开全部
有两种方法。一种是还是在原来的窗口上打开。另一种是新窗口上打开。
代码如下:
1.原来的窗口
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate2 WebBrowser1.Document.activeElement.href
End Sub
2.新窗口
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim NFrm As New Form1
NFrm.WebBrowser1.RegisterAsBrowser = True
Set ppDisp = NFrm.WebBrowser1.Object
NFrm.Visible = True
End Sub
代码如下:
1.原来的窗口
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate2 WebBrowser1.Document.activeElement.href
End Sub
2.新窗口
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim NFrm As New Form1
NFrm.WebBrowser1.RegisterAsBrowser = True
Set ppDisp = NFrm.WebBrowser1.Object
NFrm.Visible = True
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询