IE onPaste event using javascript not HTML

It seems that the only way to add the onPaste event to the input element is to use HTML:

<textarea id="text_area" onpaste="on_paste" />

not the ability to attach an event handler using javascript:

document.getElementById('text_area').onPaste = function() { alert('I iz in ur textbox, pasting some text') };

On the MSDN website, you can add event handlers for onPaste using jscript or HTML, but I want to do this in javascript. Is there any way to do this?

+3
source share
2 answers

Try typing lowercase:

document.getElementById('text_area').onpaste = ...
+3
source

Capitalized you want:

document.getElementById('text_area').onpaste = function() { alert('I iz in ur textbox, pasting some text') };
+3
source

Source: https://habr.com/ru/post/1703192/


All Articles