Udostępnij za pośrednictwem


WindowClosing event

Fires when the window of the object is about to be closed by script.

Syntax

HTML Attribute <element WindowClosing = "handler(event)">
attachEvent Method object.attachEvent("WindowClosing", handler)

 

Event information

Synchronous No
Bubbles No
Cancelable No

 

Event handler parameters

bIsChildWindow [in]

Type: Boolean

A Boolean that specifies whether the window was created from script. Can be one of the following values.

VARIANT_FALSE (false)

Window was not created from script.

VARIANT_TRUE (true)

Window was created from script.

Cancel [in, out, ref]

Type: Boolean

A Boolean value that specifies whether the window is prevented from closing. Can be one of the following values.

VARIANT_FALSE (false)

Window is allowed to close.

VARIANT_TRUE (true)

Window is prevented from closing.

Remarks

This event is fired when a window is closed from script, by using the window.close method.

The default behavior of Windows Internet Explorer is to close windows that were created by script without asking the user. If an attempt is made to close the main InternetExplorer window or the WebBrowser control window through script, the user is prompted.

This event is available only to an application that is hosting the WebBrowser control installed by Microsoft Internet Explorer 5.5 and later.

The following example indicates how the WindowClosing event could be used to allow only windows created from script to be closed through a call to window.close.

Private Sub WebBrowser1_WindowClosing(ByVal IsChildWindow As Boolean, 
        Cancel As Boolean)
  If ( IsChildWindow ) Then
    Cancel = True
  Else
    Cancel = False
  End If
End Sub