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

이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 함께 해서 번역을 마치도록 도와 주세요!

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 onpaste property returns the onPaste event handler code on the current element.

Syntax

element.onpaste = functionRef;

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

Example

<!DOCTYPE html>
<html>
<head>
<title>onpaste event example</title>
</head>

<body>
<h1>Play with this editor!</h1>
<textarea id="editor" rows="3" cols="80">
Try pasting text into this area!
</textarea>

<script>
function log(txt) {
  document.getElementById("log").appendChild(document.createTextNode(txt + "\n"));
}
  
function pasteIntercept(evt) {
  log("Pasting!");
}
  
document.getElementById("editor").addEventListener("paste", pasteIntercept, false);
</script>

<h2>Log</h2>
<textarea rows="15" cols="80" id="log" readonly="true"></textarea>
</body>
</html>

This example logs pastes into a textarea.

Notes

This event is sent when the user attempts to paste 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.

Notes

There is currently no DOM-only way to obtain the text being pasted; you'll have to use an nsIClipboard to get that information.

See also

문서 태그 및 공헌자

 이 페이지의 공헌자: fscholz, teoli, kscarfone, nairakhil13, Sheppy, ethertank, ziyunfei, Mgjbot, Potappo
 최종 변경: fscholz,