Contents Index Topic Contents | ||
Previous Topic: IHTMLBodyElement::put_onbeforeunload Next Topic: IHTMLBodyElement::createTextRange |
IHTMLBodyElement::get_onbeforeunload
HRESULT get_onbeforeunload( VARIANT *p );Retrieves the inline script associated with the onbeforeunload event on the BODY element.
- Returns S_OK if successful, or an error value otherwise.
- p
- Address of a VARIANT structure to store 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 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 put_onbeforeunload
IHTMLBodyElement::put_onbeforeunload
HRESULT put_onbeforeunload( VARIANT v );Sets the inline script associated with the onbeforeunload event on the BODY element.
- Returns S_OK if successful, or an error value otherwise.
- v
- VARIANT structure containing 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 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.