jQuery jHTMLArea 复制和粘贴问题
我正在使用 jQuery 的 jHTMLArea ,它工作得很好,但是当用户从网页复制内容并将其粘贴到编辑器中时,一旦保存,它也会复制所有 html 格式。
有没有办法去掉所有 HTML 标签的粘贴内容?
用户将不具备使用源代码视图的知识。
干杯
I am using jQuery's jHTMLArea and its working great however when a user copies content from a webpage and pastes it into the editor, once saved it also copies all the html formatting.
Is there a way to strip any pasted content of all HTML tags?
The users will not have the knowledge to use the source code view.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我之前尝试解决同样的问题,但遇到了一些障碍。问题是操作系统将内容的格式与文本一起复制到剪贴板,因此如果您尝试将 html 粘贴回任何文本区域(或 html 格式区域),您将恢复内容的格式。
幸运的是,Jquery 为您提供了对文档剪贴板的一些控制,因此理想情况下,技巧是拦截粘贴,将内容粘贴到隐藏的文本字段(不会抓取格式),然后将内容复制回 jhtmlArea。几周前我尝试这样做,但收效甚微,但我现在要再看一下,看看我是否能想出一些办法。
捕获粘贴输入可能会为您指明正确的方向
祝您好运
I tried to solve this same problem before and ran into a few roadblocks. The issue is that the os copies the content's format along with the text to your clipboard, so if you try pasting html back into ANY textarea (or html-formattable area) youll get your content back formatted.
Luckily Jquery gives you some control over the document's clipboard, so ideally the trick would be to intercept paste, paste the content into a hidden textfield (which wont grab formatting) and then copy the contents back into the jhtmlArea. I tried doing this a couple weeks ago with little success, but Im gonna take another look at it now and see if I can come up with something.
Catch paste input Might point you in the right direction
Good luck