Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Nos bénévoles n'ont pas encore traduit cet article en Français. Aidez-nous à réaliser cette tâche !

Non-standard
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.

Summary

The oncut property returns the onCut event handler code on the current element.

Syntax

element.oncut = functionRef;

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

Example

<html>
<head>
<title>oncut event example</title>

<script>
function log(txt) {
    document.getElementById("log").appendChild(document.createTextNode(txt + "\n"));
}
</script>
</head>

<body>
<h3>Play with this editor!</h3>
<textarea rows="3" cols="80" oncopy="log('Copied!');" oncut="log('Cut blocked!'); return false;">
  Try copying and cutting the text in this area!
</textarea>
<h3>Log</h3>
<textarea rows="15" cols="80" id="log" readonly="true"></textarea>
</body>
</html>

This example allows text to be copied from the textarea, but doesn't allow text to be cut. It also logs each copy and cut attempt.

Notes

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

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

Specification

Not part of specification.

See also

Étiquettes et contributeurs liés au document

 Contributeurs à cette page : fscholz, teoli, kscarfone, nairakhil13, Sheppy, ethertank, ziyunfei, Mgjbot, Potappo
 Dernière mise à jour par : fscholz,