Element.oncut

  • Revision slug: DOM/element.oncut
  • Revision title: element.oncut
  • Revision id: 310861
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

{{ DomRef() }} {{ Fx_minversion_header(3) }}

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.

Specification

Not part of specification.

See also

Revision Source

<div>{{ DomRef() }} {{ Fx_minversion_header(3) }}</div>

<h2 id="Summary" name="Summary">Summary</h2>
<p>The <strong>oncut</strong> property returns the onCut event handler code on the current element.</p>



<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<em>element</em>.oncut = <em>functionRef</em>;
</pre>
<p>where <em>functionRef</em> is a function - often a name of a function declared elsewhere or a <em>function expression</em>. See <a href="/en-US/docs/Core_JavaScript_1.5_Reference/Functions" title="Core_JavaScript_1.5_Reference/Functions">Core JavaScript 1.5 Reference:Functions</a> for details.</p>



<h2 id="Example" name="Example">Example</h2>
<pre class="brush:html">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;oncut event example&lt;/title&gt;

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

&lt;body&gt;
&lt;h3&gt;Play with this editor!&lt;/h3&gt;
&lt;textarea rows="3" cols="80" oncopy="log('Copied!');" oncut="log('Cut blocked!'); return false;"&gt;
  Try copying and cutting the text in this area!
&lt;/textarea&gt;
&lt;h3&gt;Log&lt;/h3&gt;
&lt;textarea rows="15" cols="80" id="log" readonly="true"&gt;&lt;/textarea&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>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.</p>



<h2 id="Notes" name="Notes">Notes</h2>
<p>This event is sent when the user attempts to cut text.</p>



<h2 id="Specification" name="Specification">Specification</h2>
<p>Not part of specification.</p>



<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li><code><a href="/en-US/docs/DOM/element.oncopy" title="DOM/element.oncopy">oncopy</a></code></li>
  <li><code><a href="/en-US/docs/DOM/element.onpaste" title="DOM/element.onpaste">onpaste</a></code></li>
</ul>
Revert to this revision