粘贴后是否会发生事件? [英] Is there an event that occurs after paste?

查看:77
本文介绍了粘贴后是否会发生事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

使用ctrl + v或右键单击检测粘贴的文本 - >粘贴

我正在编写一个js编辑器。
我想在粘贴之后做一些事情(检测粘贴的文本等)。

I'm coding a js editor now. I want to do something (detect pasted text, etc.) just after the paste.

推荐答案

这是一个例子处理粘贴事件:

Here's an example of handling paste event:

http://www.quirksmode.org/dom/events/tests/cutcopypaste.html

许多浏览器都支持它,但不是100% - 请参阅此表为兼容性: http://www.quirksmode.org/dom/events/cutcopypaste。 html

It's supported on many browsers but not 100% - see this table for compatibility: http://www.quirksmode.org/dom/events/cutcopypaste.html

您还可以通过以下方式解决在某些浏览器上没有粘贴事件的问题:

You can also work around not having a paste event on some browsers by:


  • 在某个时间记住表单字段的完整内容

  • Remembering full contents of the form field at some time

设置超时事件

在超时时,再次获取该字段的内容,与之前的内容进行比较,并检测更改。泡沫,冲洗,重复

On timeout, take the contents of the field again, compare to the previous contents, and detect changes. Lather, rinse, repeat

这篇关于粘贴后是否会发生事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆