onbeforecut event

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;

Event information

SynchronousNo
BubblesNo
CancelableNo

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:

  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 of the clipboardData object.
  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.

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>

See also

a
address
area
b
bdo
blockQuote
body
button
caption
cite
code
custom
dd
div
dl
dt
em
embed
fieldSet
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
map
ol
p
pre
rt
ruby
s
samp
select
small
span
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
tr
u
ul
var
Reference
onbeforecopy
onbeforepaste
oncopy
oncut
onpaste
setData
Conceptual
About DHTML Data Transfer

 

 

Send comments about this topic to Microsoft

Build date: 11/14/2012

Show:
© 2014 Microsoft