VB动态添加WebBrowser控件,并拦截弹出窗口(不用引用任何组件)

新建空白窗体,然后粘帖下面代码:

Option Explicit
Public WithEvents br As VBControlExtender

Private Sub br_ObjectEvent(Info As EventInfo)
If Info.Name = "NewWindow2" Then
    'Dim fm As New Form1
    'fm.Show
    'Info.EventParameters(0) = br.object '根据需要可实现在自己的新开窗口打开弹出窗口
    Info.EventParameters(1) = True ‘拦截弹出窗口
End If
End Sub

Private Sub Form_Click()
br.object.Navigate "http://www.918Le.com/"  '轻松网络赚钱方法
End Sub

Private Sub Form_Load()
On Error Resume Next
If Licenses.Count = 0 Then Licenses.Add "Shell.Explorer.2", "Shell.Explorer.2"
Set br = Me.Controls.Add("Shell.Explorer.2", "br")
'br.Width = 150 * Screen.TwipsPerPixelX
'br.Height = 50 * Screen.TwipsPerPixelY
br.Visible = True
End Sub

上一篇:Android学习之基础知识五—ListView控件(最常用和最难用的控件)


下一篇:使用JavaScript获取URL中的参数(两种方法)