IHTMLBodyElement::get_onbeforeunloadIHTMLBodyElement::get_onbeforeunload*
*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.

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:

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

Up Top of Page


IHTMLBodyElement::put_onbeforeunload


HRESULT put_onbeforeunload(
    VARIANT v
);

Sets the inline script associated with the onbeforeunload event on the BODY element.

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:

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


Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.