如何访问 contentEditable 元素中拖放(或粘贴)操作的结果?
我有一个 contentEditable 元素应该接受拖放操作,但我想修改正在删除(或粘贴)的内容,因为一些 HTML 标签应该被容忍,而另一些则不能。
但是我如何访问已复制的内容而不是整个元素呢?当我监听可编辑元素上的事件时,整个可编辑元素就是上下文(显然)......?并且事件本身似乎不包含正在复制的内容(FF 和 Webkit 之间有所不同)。
有什么想法吗?
I have a contentEditable element that should accept drag'n drop actions but I'd like to modify what is being dropped (or pasted) because some HTML tags should be tolerated while others shouldn't.
But how do I access just what has been copied instead of the whole element? When I listen to events on the editable element, then the whole editable element is the context (obviously)...? and the event itself does not seem to contain what is being copied (and is different between FF and Webkit).
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我今天发布了一个类似的问题,措辞不同,用户 Binary9 给出了精彩的回答: 在 contentEditable 元素中拖放事件
这个问题确实应该关闭,但我不知道该怎么做。
I posted a similar question today, worded differently, and it was brilliantly answered by user Binary9: Drag and drop event in a contentEditable element
This question should really be closed but I don't know how to do that.