最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

fire a "paste" event in Javascript - Stack Overflow

programmeradmin0浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 2

Try 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.

发布评论

评论列表(0)

  1. 暂无评论