Fires on the target object when the user pastes data, transferring the data from the system clipboard to the document.
If the event bubbles and is cancellable, return VARIANT_TRUE to prevent the event from bubbling to other event handlers in the document tree. Return VARIANT_FALSE to allow bubbling.
The DISPID for this event is defined in mshtmdid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.
Bubbles Yes Cancels Yes To invoke After copying or cutting the text:
- Right-click to display the shortcut menu and select Paste.
- Or press CTRL+V.
Default action Inserts the data from the system clipboard into the specified location on the document.
Creating custom code to enable the Paste command requires several steps.
- Set the event object returnValue to FALSE in the HTMLScriptEvents::onbeforepaste event to enable the Paste shortcut menu item.
- Cancel the default behavior of the client by setting the event object returnValue to FALSE in the HTMLScriptEvents::onpaste event handler. This applies only to objects, such as the text box, that have a default behavior defined for them.
- Specify a data format in which to paste the selection through the IHTMLDataTransfer::getData method of the clipboardData object.
- Invoke the method in the HTMLScriptEvents::onpaste event to execute custom paste code.