onpaste event
Examples
On the <input> element in the implementation of JavaScript when pasting text:
try it"
You can see more examples at the bottom of this article.
Definition and Usage
onpaste event is triggered when the user to paste the text element.
Note: While HTML elements use support onpaste events, but in fact does not support all elements such as <p> element, unless the (See below for more examples) contenteditable as "true".
Tip: onpaste event is often used type = "text" of the <input> elements.
Tip: There are three ways you can paste the contents of elements:
- Press CTRL + V
- Select "Paste (Paste)" from your browser's Edit menu
- Right-click the mouse button to select "Paste (Paste)" command in the context menu.
Browser Support
event | |||||
---|---|---|---|---|---|
onpaste | Yes | Yes | Yes | Yes | Yes |
grammar
In HTML:
In JavaScript:
JavaScript, use the addEventListener () method:
Note: Internet Explorer 8 and earlier versions of IE do not support addEventListener () method.
technical details
Whether to support the bubble: | Yes |
---|---|
It can be canceled: | Yes |
Event Type: | ClipboardEvent |
Supported HTML tags: | All HTML elements |
More examples
Examples
JavaScript to execute when the <p> element and paste text (note contenteditable set to "true"):
try it"
Related Pages
HTML DOM Reference: oncopy event
HTML DOM Reference: oncut event
Event objects