Open a new window using your own browser

xiaoxiao2021-03-06  48

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

AskWEBBBROWSEREVENTS2_NEWINDOW2EVENT) HANDLES AXWEBBROWSER1.NEWWINDOW2

e.cancel =

True

End

Sub

Alternative You Could Instantiate An InternetExplorer Object and Pass The Handle To That, In this Way You CAN Trap What They Do I 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 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 SubBut I guess the First Is Simpler As It Just Stops Them Being Able To Do IT ALL.

转载请注明原文地址:https://www.9cbs.com/read-117115.html

New Post(0)