Events


BeforeNavigate Event

Description

Occurs when the WebBrowser control is about to navigate to a different URL, which may happen as a result of external automation, internal automation from a script, or the user clicking a link or typing in the address bar. The container has an opportunity to cancel the pending navigation.

Syntax

Private Sub object_BeforeNavigate(ByVal URL As String, ByVal Flags As Long,
ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String,
Cancel As Boolean)

ValueDescription
object Required. An object expression that evaluates to an object in the Applies To list.
URL A string expression that evaluates to the URL to which the browser is navigating.
Flags Reserved for future use.
TargetFrameName A string expression that evaluates to the name of the frame in which to display the resource, or NULL if no named frame is targeted for the resource.
PostData Data to send to the server if the HTTP POST transaction is being used.
Headers A value that specifies the additional HTTP headers to send to the server (HTTP URLs only). The headers can specify such things as the action required of the server, the type of data being passed to the server, or a status code.
Cancel A Boolean value that the container can set to True to cancel the navigation operation, or to False to allow it to proceed.

Applies To

WebBrowser, WebBrowserApp

See Also

Navigate, NavigateComplete


CommandStateChange Event

Description

Occurs when the enabled state of a command changes.

Syntax

Private Sub object_CommandStateChange (ByVal Command As Long,
ByVal Enable As Boolean)

ValueDescription
object An object expression that evaluates to an object in the Applies To list.
Command A long integer specifying the identifier of the command that changed.
Enable A Boolean value that is True if the command is enabled, or False if not.

Applies To

WebBrowser, WebBrowserApp


DownloadBegin Event

Description

Occurs when a navigation operation is beginning. This event is fired shortly after the BeforeNavigate event, unless the navigation is canceled. Any animation or "busy" indication that the container needs to display should be connected to this event.

Syntax

Private Sub object_DownloadBegin ( )

ValueDescription
object An object expression that evaluates to an object in the Applies To list.

Applies To

WebBrowser, WebBrowserApp

See Also

DownloadComplete, Navigate, ProgressChange


DownloadComplete Event

Description

Occurs when a navigation operation finished, was halted, or failed. Unlike NavigateComplete, which is fired only when a URL is successfully navigated to, this event is always fired after a navigation starts. Any animation or "busy" indication that the container needs to display should be connected to this event.

Syntax

Private Sub object_DownloadComplete ( )

ValueDescription
object An object expression that evaluates to an object in the Applies To list.

Applies To

WebBrowser, WebBrowserApp

See Also

DownloadBegin, Navigate, NavigateComplete, ProgressChange


NavigateComplete Event

Description

Occurs after the browser has successfully navigated to a new location. The document may still be downloading (and in the case of HTML, images may still be downloading), but at least part of the document has been received from the server, and the viewer for the document has been created.

Syntax

Private Sub object_NavigateComplete(ByVal URL As String)

ValueDescription
object An object expression that evaluates to an object in the Applies To list.
URL A string expression that evaluates to the URL that was navigated to. Note that this URL can be different from the URL that the browser was told to navigate to. One reason is that this URL is the canonicalized and qualified URL; for instance, if an application specified a URL of "www.microsoft.com" in a call to the Navigate method, the URL passed by NavigateComplete will be "http://www.microsoft.com/". Also, if the server has redirected the browser to a different URL, the redirected URL will be reflected here.

Applies To

WebBrowser, WebBrowserApp

See Also

BeforeNavigate, Navigate


NewWindow Event

Description

Occurs when a new window is to be created for displaying a resource. Some actions that can cause this include the user shift-clicking on a link, the user right-clicking on a link and choosing "open in new window", or a targeted navigation to a frame name that does not yet exist. The container has an opportunity to handle the new window creation itself. If it does not, a top-level Internet Explorer window is created as a separate process.

Syntax

Private object_NewWindow (ByVal URL As String, ByVal Flags As Long,
ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String,
Processed As Boolean)

ValueDescription
object An object expression that evaluates to an object in the Applies To list.
URL A string expression that evaluates to the URL of the resource being navigated to.
Flags Reserved for future use.
TargetFrameName A string expression that evaluates to the name of the frame in which to display the resource, or NULL if no named frame is targeted for the resource.
PostData Data to send to the server if an HTTP POST transaction is used.
Headers A value that specifies the HTTP headers to send to the server (HTTP URLs only). The headers can specify such things as the action required of the server, the type of data being passed to the server, or a status code.
Processed A Boolean value that indicates whether the container intends to create the new window. Set this parameter to True if the container will create the window, or to False if a top-level Internet Explorer window is to be created.

Remarks

The preferred behavior of WebBrowser control containers is to process this event, create a new instance of the WebBrowser control, and pass all the parameters from the NewWindow event directly to the Navigate method on the newly created WebBrowser control. Another option for containers that cannot or do not need to create a new window is to degrade by performing the navigation in the existing window. To do this, they may process this event and then pass the parameters from this event to Navigate on the existing window.

Applies To

WebBrowser, WebBrowserApp

See Also

BeforeNavigate, Navigate, NavigateComplete


ProgressChange Event

Description

Occurs when the progress of a download operation is updated.

Syntax

Private Sub object_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)

ValueDescription
object An object expression that evaluates to an object in the Applies To list.
Progress A long integer that specifies the amount of total progress to show, or -1 when progress is complete.
ProgressMax A long integer that specifies the maximum progress value.

Remarks

The container can use the information provided by this event to display the number of bytes downloaded so far or to update a progress indicator.

To calculate the percentage of progress to show in a progress indicator, multiply the value of Progress by 100 and divide by the value of ProgressMax (unless progress is -1, in which case the container can indicate that the operation is finished or hide the progress indicator).

Applies To

WebBrowser, WebBrowserApp

See Also

DownloadBegin, DownloadComplete, Navigate


PropertyChange Event

Description

Occurs when the PutProperty method changes the value of a property.

Syntax

Private Sub object_PropertyChange(ByVal szProperty As String)

ValueDescription
object An object expression that evaluates to an object in the Applies To list.
szProperty A string expression that contains the name of the property whose value has changed.

Applies To

WebBrowserApp

See Also

GetProperty, PutProperty


Quit Event

Description

Occurs when the Internet Explorer application is ready to quit.

Syntax

Private Sub object_Quit(Cancel As Boolean)

ValueDescription
object An object expression that evaluates to an object in the Applies To list.
Cancel A Boolean value that is True if the last Quit was canceled, or False if not.

Applies To

WebBrowserApp

See Also

Quit


StatusTextChange Event

Description

Occurs when the status bar text has changed.

Syntax

Private Sub object_StatusTextChange(ByVal Text As String)

ValueDescription
object An object expression that evaluates to an object in the Applies To list.
Text A string containing the new status bar text.

Remarks

The container can use the information provided by this event to update the text of a status bar.

Applies To

WebBrowser, WebBrowserApp

See Also

StatusBar, StatusText


TitleChange Event

Description

Occurs when the title of a document in the WebBrowser control becomes available or changes. For HTML, the title may change; while HTML is still downloading, the URL of the document is set as the title. After the real title (if there is one) is parsed from the HTML, the title is changed to reflect the actual title.

Syntax

Private Sub object_TitleChange(ByVal Text As String)

ValueDescription
object An object expression that evaluates to an object in the Applies To list.
Text A string containing the new document title.

Applies To

WebBrowser, WebBrowserApp


WindowActivate Event

Description

Occurs when the Internet Explorer main window has been activated.

Syntax

Private Sub object_WindowActivate( )

ValueDescription
object An object expression that evaluates to an object in the Applies To list.

Applies To

WebBrowserApp

See Also

WindowMove, WindowResize


WindowMove Event

Description

Occurs when the Internet Explorer main window has been moved.

Syntax

Private Sub object_WindowMove( )

ValueDescription
object An object expression that evaluates to an object in the Applies To list.

Applies To

WebBrowserApp

See Also

WindowActivate, WindowResize


WindowResize Event

Description

Occurs when the size of the Internet Explorer main window has changed.

Syntax

Private Sub object_WindowResize( )

ValueDescription
object An object expression that evaluates to an object in the Applies To list.

Applies To

WebBrowserApp

See Also

WindowActivate, WindowMove

© 1996 Microsoft Corporation