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 copied to the system clipboard.
Syntax
| HTML Attribute | <element onbeforecopy = "handler(event)"> |
|---|---|
| Event Property | object.onbeforecopy = handler; |
| attachEvent Method | object.attachEvent("onbeforecopy", handler) |
| addEventListener Method | object.addEventListener("beforecopy", 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
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.
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 onbeforecopy event to customize copy behavior.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/onbeforecopyEX.htm
<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
- acronym
- address
- applet
- area
- b
- base
- baseFont
- bdo
- bgSound
- big
- blockQuote
- body
- br
- button
- caption
- center
- cite
- code
- col
- colGroup
- comment
- custom
- dd
- del
- dfn
- dir
- div
- dl
- dt
- em
- embed
- fieldSet
- font
- form
- frame
- frameSet
- 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
- isIndex
- kbd
- label
- legend
- li
- link
- listing
- map
- marquee
- menu
- nextID
- noBR
- noFrames
- noScript
- object
- ol
- option
- p
- plainText
- pre
- q
- rt
- ruby
- s
- samp
- script
- select
- small
- span
- strike
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- title
- tr
- tt
- u
- ul
- var
- wbr
- xml
- xmp
- Reference
- onbeforecut
- onbeforepaste
- oncopy
- oncut
- onpaste
- setData
- Conceptual
- About DHTML Data Transfer
Send comments about this topic to Microsoft
Build date: 12/5/2012