This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

beforecut

Overview Table

Synchronous No
Bubbles No
Target dom/Element
Cancelable No
Default action ?
## Examples

This example uses the setData and getData methods with the ClipboardData object to perform a cut-and-paste operation through the shortcut menu.

<head>
<script>
var sSave = "";
function fnBeforeCut() {
   event.returnValue = false;
}
function fnCut() {
   event.returnValue = false;
   sSave = oSource.innerText;
   oSource.innerText = "";
}
function fnBeforePaste() {
   event.returnValue = false;
}
function fnPaste() {
   event.returnValue = false;
   oTarget.innerText = sSave;
}
</script>
</head>
<body>
<div id="oSource" class="selectandcut"
    onbeforecut="fnBeforeCut()"
    oncut="fnCut()">Select and Cut this Text
</div>
<br>
<br>
<div id="oTarget" class="pastehere"
    onbeforepaste="fnBeforePaste()"
    onpaste="fnPaste()">Paste the Text Here
</div>
</body>

View live example

Notes

Remarks

Creating custom code for cutting requires several steps:

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

None. 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:

  • HTMLAnchorEvents2
  • HTMLAreaEvents2
  • HTMLButtonElementEvents2
  • HTMLControlElementEvents2
  • HTMLDocumentEvents2
  • HTMLElementEvents2
  • HTMLFormElementEvents2
  • HTMLImgEvents2
  • HTMLFrameSiteEvents2
  • HTMLInputFileElementEvents2
  • HTMLInputImageEvents2
  • HTMLInputTextElementEvents2
  • HTMLLabelEvents2
  • HTMLLinkElementEvents2
  • HTMLMapEvents2
  • HTMLMarqueeElementEvents2
  • HTMLObjectElementEvents2
  • HTMLOptionButtonElementEvents2
  • HTMLScriptEvents2
  • HTMLSelectElementEvents2
  • HTMLStyleElementEvents2
  • HTMLTableEvents2
  • HTMLTextContainerEvents2
  • HTMLWindowEvents2

Syntax

Standards information

There are no standards that apply here.

Event handler parameters

pEvtObj [in]
Type: ****IHTMLEventObj****

Attributions