使用你自己的浏览器打开新窗口

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

选择自 http://dev.csdn.net/user/2066 的 Blog

If you trap the NewWindow2 event for the WebBrowser control, you can stop all new windows opening, like this:

Code:

Private Sub AxWebBrowser1_NewWindow2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles AxWebBrowser1.NewWindow2

e.cancel = True

End Sub

Alternatively you could instantiate an InternetExplorer object and pass the handle to that, in this way you can trap what they do in InternetExplorer too.

Code:

Dim WithEvents ieChildBrowser As SHDocVw.InternetExplorer

Private Sub AxWebBrowser1_NewWindow2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles AxWebBrowser1.NewWindow2

ieChildBrowser = New SHDocVw.InternetExplorer()

ieChildBrowser.RegisterAsBrowser = True

e.ppDisp = ieChildBrowser

End Sub

Now you can trap the DownloadBegin event, cut out the URL they were going to, close the instance of IE, then Navigate2 in your own WebBrowser.

Code:

Private Sub ieChildBrowser_DownloadBegin(ByVal sender As Object, ByVal e As System.EventArgs) Handles ieChildBrowser.DownloadBegin

Dim strURL As String

strURL = ieChildBrowser.Document.URL

ieChildBrowser.Quit()

ieChildBrowser = Nothing

AxWebBrowser1.Navigate2(strURL)

End Sub

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航