Contents Index Topic Contents | ||
Previous Topic: IHTMLWindow2::get_offscreenBuffering Next Topic: IHTMLWindow2::get_onblur |
IHTMLWindow2::get_onbeforeunload
HRESULT get_onbeforeunload( VARIANT *p );Retrieves the inline script associated with the onbeforeunload event before a window element is unloaded. This event is fired before the onunload event. It provides an opportunity to warn the user if the window is currently in an unsaved state and the information will be lost.
For more information on inline script, see Attaching an Event Handler in the Event Model documentation.
- Returns S_OK if successful, or an error value otherwise.
- p
- Address of a VARIANT structure that contains the script.
The handler for this event should return NULL if doing the unload is safe, or a text string to prompt the user to decide to cancel or continue with the unload operation. Only the user's response to the warning can stop the new navigation causing the unload; the event handler itself cannot unilaterally block the operation. If the handler returns a non-NULL string, a modal dialog box appears that displays the explanatory string. The dialog box shows three buttons with the message for user action:
- Continuethe unload operation proceeds.
- Cancelthe navigation causing the unload is immediately canceled.
- Help(strongly recommended)displays additional explanatory text, such as "This operation may cause existing content information to be lost. Choose Continue if this is OK, or Cancel to retain the information."
In the case of frames, the full sequence of onbeforeunload events are fired on each frame in the same order, depth-first, that onunload events are about to be fired. A dialog box is presented for each event handler that returns a non-NULL string. The first Cancel response stops the potential navigation, in which case no unload occurs. If there is no Cancel response, the unload proceeds and onunload events fire.
See also put_onbeforeunload
IHTMLWindow2::put_onbeforeunload
HRESULT put_onbeforeunload( VARIANT v );Sets the inline script associated with the onbeforeunload event before a window element is unloaded. This event is fired before the onunload event. It provides an opportunity to warn the user if the window is currently in an unsaved state and the information will be lost.
For more information on inline script, see Attaching an Event Handler in the Event Model documentation.
- Returns S_OK if successful, or an error value otherwise.
- v
- VARIANT structure that contains the script to be set.
The handler for this event should return NULL if doing the unload is safe, or a text string to prompt the user to decide to cancel or continue with the unload operation. Only the user's response to the warning can stop the new navigation causing the unload; the event handler itself cannot unilaterally block the operation. If the handler returns a non-NULL string, a modal dialog box appears that displays the explanatory string. The dialog box shows three buttons with the message for user action:
- Continuethe unload operation proceeds.
- Cancelthe navigation causing the unload is immediately canceled.
- Help(strongly recommended)displays additional explanatory text, such as "This operation may cause existing content information to be lost. Choose Continue if this is OK, or Cancel to retain the information."
In the case of frames, the full sequence of onbeforeunload events is fired on each frame in the same order, depth-first, that onunload events are about to be fired. A dialog box is presented for each event handler that returns a non-NULL string. The first Cancel response stops the potential navigation, in which case no unload occurs. If there is no Cancel response, the unload proceeds and onunload events fire.
See also get_onbeforeunload
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.