Retrieves a pointer to the event handler function associated with the onbeforeunload event before a FRAME element is unloaded.
Syntax
HRESULT get_onbeforeunload( VARIANT *p );
Parameters
- p
- Address of a VARIANT structure that returns the script.
Return Value
Returns S_OK if successful, or an error code otherwise.
Remarks
This event is fired before the onunload event. It provides an opportunity to warn the user if the window currently is in an unsaved state and the information will be lost.
Use the following code fragment to obtain an event handler.pBody->get_onEvent( &_variant_t(pDisp) ); // pDisp a pointer to an IDispatch interface // pBody a pointer to an element of interest
Sets a pointer to the event handler function associated with the onbeforeunload event before a FRAME element is unloaded.
Syntax
HRESULT put_onbeforeunload( VARIANT v );
Parameters
- v
- VARIANT structure that contains a string that specifies the script to set.
Return Value
Returns S_OK if successful, or an error code otherwise.
Remarks
This event is fired before the onunload event. It provides an opportunity to warn the user if the window currently is in an unsaved state and the information will be lost.
Use the following code fragment to set an event handler. This method will only add a single event handler. To add multiple event handlers, see the IHTMLDocument3::attachEvent, IHTMLElement2::attachEvent, and IHTMLWindow3::attachEvent methods.
pBody->put_onEvent( &_variant_t(pDisp) ); // pDisp a pointer to an IDispatch interface // pBody a pointer to an element of interest