如何捕获contentEditable粘贴事件? [英] How can you catch a contentEditable paste event?

查看:358
本文介绍了如何捕获contentEditable粘贴事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很好的可编辑文本区域,有 wysihat 和contentEditable。我真的需要一种拦截粘贴事件的方法来阻止它们,或者在允许插入之前处理它们的DOM。人们可以将整个网页粘贴到可编辑区域,这有点疯狂。

I've got a great editable text area going with wysihat and contentEditable. I really need a way to intercept paste events to either stop them, or process their DOM before allowing insertion. It's a little crazy they people can paste entire webpages into the editable areas.

这可能吗?

来吧在未来,到达我的家门口。 HTML5专家,火!

Come on future, arrive on my doorstep. HTML5 gurus, fire!

推荐答案

您无法访问将要插入的内容。

You can't access the content's that will be inserted.

你可以做的是添加一个事件监听器,在Ctrl + V上运行一些清理代码(超时,所以它看到粘贴的文本)

What you can do is add an event listener that runs some cleanup code on Ctrl+V (with a timeout, so it sees the pasted text)

这篇关于如何捕获contentEditable粘贴事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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