Visit Mozilla.org

DOM:element.oncut

From MDC

This article covers features introduced in Firefox 3

« Gecko DOM Reference

Contents

[edit] Summary

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

[edit] 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.

[edit] 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.

[edit] Notes

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

[edit] Specification

Not part of specification.

[edit] See also