DOM:element.onpaste
出典: MDC
この記事は Firefox 3 の新機能について述べています
目次 |
[編集] 概要
onpaste プロパティは、現在の要素での onPaste イベントハンドラのコードを返します。
[編集] 構文
element.onpaste = functionRef;
ここでの functionRef は、関数です。それは、たいてい、他の場所で宣言された関数の名前、あるいは、function 式 です。Core JavaScript 1.5 Reference:Functions を参照してください。
[編集] 例
<html>
<head>
<title>onpaste event example</title>
</head>
<body>
<h3>Play with this editor!</h3>
<textarea id="editor" rows="3" cols="80">
Try pasting text into this area!
</textarea>
<script type="text/javascript">
function log(txt)
{
document.getElementById("log").appendChild(document.createTextNode(txt + "\n"));
}
function pasteIntercept(evt)
{
log("Pasting!");
}
document.getElementById("editor").addEventListener("paste", pasteIntercept, false);
</script>
<h3>Log</h3>
<textarea rows="15" cols="80" id="log" readonly="true"></textarea>
</body>
</html>
この例は、テキストエリアへの貼り付けのログを表示します。
[編集] 注記
このイベントは、ユーザがテキストを貼り付けしようとしたときに発生します。
[編集] 仕様
仕様の一部ではありません。
[編集] 注記
現在、 DOM だけでペーストされたテキストを得る方法はありません。その情報を得るためには、nsIClipboard を用いる必要があります。