문제

I'm using htmlarea for my little CMS, and I was wondering if it's possible to detect if something gets pasted into it with jQuery?

도움이 되었습니까?

해결책

Try adding an Event Listener to your textarea for "keydown," and then looking out for keyCode == 86, that's the paste event. Now you can do whatever you want to happen when a user tries to paste.

Like this:

document.getElementById('YOURhtmlArea').addEventListener('keydown', 
function (foo)
{
     if (foo.keyCode == 86)
     {
          alert('SOMEONE IS PASTING');
          foo.preventDefault();
     }
});

I hope that helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top