Visit Mozilla.org

DOM:element.oncut

出典: MDC


この記事は Firefox 3 の新機能について述べています

« Gecko DOM リファレンス

目次

[編集] 概要

oncut プロパティは、現在の要素での onCut イベントハンドラのコードを返します。

[編集] 構文

element.oncut = functionRef;

ここでの functionRef は、関数です。それは、たいてい、他の場所で宣言された関数の名前、あるいは、function 式 です。Core JavaScript 1.5 Reference:Functions を参照してください。

[編集]

<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>

この例では、テキストエリアからテキストをコピーすることはできますが、切り取ることはできません。また、コピーと切り取りの試みのログを表示します。


[編集] 注記

このイベントは、ユーザがテキストを切り取ろうとしたときに発生します。

[編集] 仕様

仕様の一部ではありません。

[編集] 参照