vb6.0 webbrowser控件做的浏览器,怎样解决ie打开新窗

页面导航:首页 > 软件编程 > vb.net > vb6.0 webbrowser控件做的浏览器,怎样解决ie打开新窗

vb6.0 webbrowser控件做的浏览器,怎样解决ie打开新窗

来源: 作者: 时间:2016-01-21 10:23 【

方法一:Private Sub Command1_Click() WebBrowser1.Navigate Text1.Text 点击Command1打开Text1的网址 End Sub Private Sub Form_Resize() If Me.WindowState 1 Then WebBrowser1.Width = Me.ScaleWidth: WebBrowser1

 方法一:
Private Sub Command1_Click()
WebBrowser1.Navigate Text1.Text 点击Command1打开Text1的网址
End Sub

Private Sub Form_Resize()
If Me.WindowState <> 1 Then WebBrowser1.Width = Me.ScaleWidth: WebBrowser1.Height = Me.ScaleHeight - WebBrowser1.Top 让Webbrowser1适应窗口大小
End Sub

Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
If Option1.Value = True Then 如果单选框Option1(在当前窗口打开)
Set ppDisp = WebBrowser2.Application
WebBrowser2.ZOrder
在Webbrowser2中打开,请跳到WebBrowser2_BeforeNavigate2看
Else 如果选择了在新窗口中打开
Dim NewForm As New Form1
NewForm.Show 弹出一个新的Form1窗口
Set ppDisp = NewForm.WebBrowser1.Application
NewForm.WebBrowser1.ZOrder
在新弹出的Form1窗口打开
End If
End Sub

Private Sub WebBrowser2_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
WebBrowser2.Stop Webbrowser2停止
WebBrowser1.Stop Webbrowser1停止
WebBrowser1.Navigate URL Webbrowser1打开网址
End Sub

方法二:
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate2 WebBrowser1.Document.activeElement.href
End Sub

方法三:
Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1
Private Sub Form_Load()
Set Web_V1 = WebBrowser1.Object
WebBrowser1.Navigate2 ""
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
     WebBrowser1.Navigate URL
End Sub

注意 这句Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1
放在通用代码里
 

Tags:

文章评论

最 近 更 新
热 点 排 行
Js与CSS工具
代码转换工具

<