I know this topic discussed many times. But this one a bit different. I need to "dispatch" a "paste" event (like after copy "paste").
Why do I need that ? Well when you copying a link into a message textarea in Facebook,you see that automatically ajax script called that alters the page so that recipient could see attached image besides the link.
since I'm not going to use Facebook API's and stuff,I just want to call the paste event that hopefully will trigger the script that I need.
I know this topic discussed many times. But this one a bit different. I need to "dispatch" a "paste" event (like after copy "paste").
Why do I need that ? Well when you copying a link into a message textarea in Facebook,you see that automatically ajax script called that alters the page so that recipient could see attached image besides the link.
since I'm not going to use Facebook API's and stuff,I just want to call the paste event that hopefully will trigger the script that I need.
Share Improve this question edited Jan 10, 2012 at 9:44 Lix 48k12 gold badges107 silver badges134 bronze badges asked Jan 9, 2012 at 14:30 IveliusIvelius 5,0138 gold badges33 silver badges54 bronze badges 4-
What you seek is probably
keydown
/keyup
events witch parison of textarea value from before and after... – Juicy Scripter Commented Jan 9, 2012 at 14:33 - Are you clear about the difference between dispatching an event and handling an event? The browser will already fire a "paste" event when the user does a paste operation on your input elements. – Pointy Commented Jan 9, 2012 at 14:35
- I know the difference between dispatching an event and handling it.And what I need is to "dispatch" one.If you know how to make a browser "fire" the "paste" event programmatically,then you know the answer for my question.Thank you :) – Ivelius Commented Jan 10, 2012 at 8:22
- Did you ever find a solution to your problem? Either by actually triggering a "paste" event or do something else? I have the same problem here. – freeall Commented Sep 19, 2012 at 11:54
1 Answer
Reset to default 2Try using document.createEvent
and the necessary arguments to imitate the "paste" action (e.g. CTRL-V
).
There is likely also a "paste" event which can be created and dispatched but browser support may (will!) vary.