DOM:element.onpaste
From MDC
This article covers features introduced in Firefox 3
Contents |
[edit] Summary
The onpaste property returns the onPaste event handler code on the current element.
[edit] Syntax
element.onpaste = 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>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>
This example logs pastes into a textarea.
[edit] Notes
This event is sent when the user attempts to paste text.
[edit] Specification
Not part of specification.
[edit] 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.