The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Fires on the source object before the selection is deleted from the document.
Syntax
| HTML Attribute | <element onbeforecut = "handler(event)"> |
|---|---|
| Event Property | object.onbeforecut = handler; |
| attachEvent Method | object.attachEvent("onbeforecut", handler) |
| addEventListener Method | object.addEventListener("beforecut", handler, useCapture) |
Event information
| Synchronous | No |
|---|---|
| Bubbles | No |
| Cancelable | No |
Event handler parameters
- pEvtObj [in]
-
Type: IHTMLEventObj
Standards information
There are no standards that apply here.
Remarks
Creating custom code for cutting requires several steps:
- Set event.returnValue=false in the onbeforecut event to enable the Cut shortcut menu item.
- Specify a data format in which to transfer the selection through the setData method of the clipboardData object.
- 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
Examples
This example uses the setData and getData methods with the clipboardData object to perform a cut-and-paste operation through the shortcut menu.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/onbeforecutEX.htm
<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>
See also
- a
- address
- applet
- area
- b
- bdo
- big
- blockQuote
- body
- button
- caption
- center
- cite
- code
- custom
- dd
- dfn
- dir
- div
- dl
- dt
- em
- embed
- fieldSet
- font
- form
- hn
- hr
- i
- img
- input type=button
- input type=checkbox
- input type=file
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- kbd
- label
- legend
- li
- listing
- map
- marquee
- menu
- nextID
- noBR
- ol
- p
- plainText
- pre
- rt
- ruby
- s
- samp
- select
- small
- span
- strike
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- tr
- tt
- u
- ul
- var
- xmp
- Reference
- onbeforecopy
- onbeforepaste
- oncopy
- oncut
- onpaste
- setData
- Conceptual
- About DHTML Data Transfer
Send comments about this topic to Microsoft
Build date: 12/5/2012