共用方式為


oncut event

Fires on the source element when the object or selection is removed from the document and added to the system clipboard.

Syntax

HTML Attribute <element oncut = "handler(event)">
Event Property object.oncut = handler;
attachEvent Method object.attachEvent("oncut", handler)
addEventListener Method object.addEventListener("cut", handler, useCapture)

 

Event information

Synchronous No
Bubbles Yes
Cancelable Yes

 

Event handler parameters

Standards information

There are no standards that apply here.

Remarks

Creating custom code for cutting requires several steps:

  1. Set event.returnValue=false in the HTMLElementEvents::onbeforecut event to enable the Cut shortcut menu item.
  2. Specify a data format in which to transfer the selection through the IHTMLDataTransfer::setData method of the clipboardData object.
  3. Invoke the IHTMLDataTransfer::setData method in the HTMLElementEvents::oncut event.

Set event.returnValue=false in the HTMLElementEvents::oncut event handler to cancel the default action. The default action must be canceled to successfully use the IHTMLDataTransfer::setData method. Web authors can use the IHTMLElement::innerHTML property or the IHTMLSelectionObject::createRange method to perform the cut operation once the event is canceled.

Removes the selection from the document and persists it in the clipboard.

To invoke this event, do one of the following:

  • Right-click to display the shortcut menu and select Cut.
  • Or press CTRL+X if the selection is within a text field.

The pEvtObj parameter is required for the following interfaces:

See also

Reference

HTMLElementEvents::onbeforecopy

HTMLElementEvents::onbeforecut

HTMLElementEvents::onbeforepaste

oncopy

HTMLElementEvents::onpaste

IHTMLDataTransfer::setData

Conceptual

About DHTML Data Transfer