在网上发现了两段代码:'原来的窗口 Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean) Cancel = True WebBrowser1.Navigate2 WebBrowser1.Document.activeElement.href End Sub'新窗口 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.Document.activeElement.href到底是什么意思啊 2.NewWindows2事件里的ppdisp到底是什么啊?
activeElement.href活动元素地址,ppdisp加载的浏览器窗体框架对象
我搜藏的方法:'将新窗口在webbrowser中打开 Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1Private Sub Form_Load() Set Web_V1 = WebBrowser1.Object 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
activeElement Property Internet Development Index --------------------------------------------------------------------------------Retrieves the object that has the focus when the parent document has focus.Syntax[ oActive = ] document.activeElement Possible ValuesoActive Object that receives the element that has the focus. The property is read-only. The property has no default value.
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate2 WebBrowser1.Document.activeElement.href
End Sub'新窗口
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.Document.activeElement.href到底是什么意思啊
2.NewWindows2事件里的ppdisp到底是什么啊?
Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1Private Sub Form_Load()
Set Web_V1 = WebBrowser1.Object
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
Possible ValuesoActive Object that receives the element that has the focus. The property is read-only. The property has no default value.
555555555现在才知道,编程不懂英文是多么可怜