如何把新窗口 打开在WEBB2中
Private Sub Command2_Click()
WebBrowser1.Document.All.tags("input")(1).Click
End Sub
如上,点击之后是调用IE打开一个新窗口
我想要的是不要在IE里打开,在我的webbrowers2中打开它
不知行不行
[最优解释]
可以,参考如何使发生在同一 web 浏览器窗口中的导航。
比如:
创建两个form,分别放一个webbrowser,form1上的为webbrowser1,form2上的为webbrowser2,在form1中复制以下代码:
Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1
Private Sub Form_Load()
Set Web_V1 = WebBrowser1.Object
Me.WebBrowser1.Navigate2 "http://www.baidu.com/s?wd=163&rsv_bp=0&rsv_spt=3&rsv_sug3=3&inputT=4000"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim frm As Form
For Each frm In Forms
If frm.Name = "Form2" Then Unload frm
Next
End Sub
Private Sub Web_V1_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
Processed = True
Dim frm As New Form2
frm.Show
frm.WebBrowser2.Navigate2 URL
End Sub