This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.


The oncopy property returns the onCopy event handler code on the current element.


element.oncopy = functionRef;

where functionRef is a function - often a name of a function declared elsewhere or a function expression. See JavaScript Reference:Functions for details.


<!DOCTYPE html>
<title>oncopy event example</title>

function log(txt) {
    document.getElementById("log").appendChild(document.createTextNode(txt + "\n"));

<div oncopy="log('Copy blocked!'); return false;">Try copying this text!</div>

<textarea rows="15" cols="80" id="log" readonly="true"></textarea>

This example prevents the text from being copied out of the browser window.


This event is sent when the user attempts to copy text.

Since Firefox 13, the preference dom.event.clipboardevents.enabled controls this feature. It defaults to true but can be disabled.


Not part of specification.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support ? Yes3 ? ? ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support ? ? Yes4 ? ? ?

See also

Document Tags and Contributors

Last updated by: fscholz,