简体   繁体   English

从div复制时防止复制html / css样式

[英]Prevent copying of html/css styles when copying from a div

When copying from a div that has applied CSS properties like font-styles and font-size to the text in them this CSS also gets copied and the pasted content is formatted as per the styles. 从已将CSS属性(如font-styles和font-size)应用到其中的文本的div复制时,此CSS也会被复制,并且粘贴的内容将按照样式进行格式化。 How can we stop this behaviour, such that when you copy from a div, not matter what styles is applies only the text part gets copied to the clipboard? 我们如何才能停止这种行为,例如,当您从div复制时,无论使用哪种样式,仅将文本部分复制到剪贴板?

This is the clipboard feature which copy the style also. 这是剪贴板功能,也可以复制样式。 I think we cannot prevent this behavior by javascript. 我认为我们无法通过javascript阻止此行为。 You can copy it in notepad then paste it so the style will not apply for the text. 您可以将其复制到记事本中,然后将其粘贴,这样样式将不适用于文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM