onbeforecopy event

Fires on the source object before the selection is copied to the system clipboard.

Syntax

HTML Attribute <element onbeforecopy = "handler(event)">
Event Property object.onbeforecopy = handler;

Event information

SynchronousNo
BubblesNo
CancelableNo

Event handler parameters

pEvtObj [in]

Type: IHTMLEventObj

Standards information

There are no standards that apply here.

Remarks

The onbeforecopy event fires on the source element. Use the setData method to specify a data format for the selection.

None.

To invoke this event, do one of the following:

  • Right-click to display the shortcut menu and select Copy.
  • Or press CTRL+C.

Examples

This example uses the onbeforecopy event to customize copy behavior.


<HEAD>
<SCRIPT>
var sNewValue = "copy event fired";
var bFired = false;
var sSave = "";
function Source_Beforecopy() 
{
  sSave = oSource.innerText;
  bFired = true;
  event.returnValue = false;
}
function Source_Copy() 
{
  window.clipboardData.setData("Text", sNewValue);
}
function Target_BeforePaste() 
{
  event.returnValue = false;
}
function Target_Paste() 
{
  event.returnValue = false;
  oTarget.value = window.clipboardData.getData("Text");
}
</SCRIPT>
</HEAD>
<BODY>
<SPAN ID=oSource onbeforecopy="Source_Beforecopy()"
       oncopy="Source_Copy()">copy this text</SPAN>
<INPUT ID=oTarget onbeforepaste="Target_BeforePaste()"
       onpaste="Target_Paste()">
</BODY>

See also

a
abbr
address
area
b
base
bdo
blockQuote
body
br
button
caption
cite
code
col
colGroup
comment
custom
dd
del
div
dl
dt
em
embed
fieldSet
form
head
hn
hr
html
i
iframe
img
input type=button
input type=checkbox
input type=file
input type=hidden
input type=image
input type=password
input type=radio
input type=reset
input type=submit
input type=text
ins
kbd
label
legend
li
link
map
object
ol
option
p
pre
q
rt
ruby
s
samp
script
select
small
span
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
title
tr
u
ul
var
wbr
Reference
onbeforecut
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