quot html复制,javascript - Copy HTML to clipboard - Stack Overflow

I use a simple third party library to copy something to clipboard.

The something is always some programming code. In these examples it is HTML and Python codes.

Copy (fail)

Copy (success)

In short: whatever is placed in data-clipboard-text attribute of a button, will be copied to the clipboard.

Please, press a Copy button in the example and insert into a text editor what there is in the clipboard.

Copy (fail) button copies the contents of its data-clipboard-text but it consists only of whitespace characters and line breaks.

Morever, when I run this at my localhost, I get this error after clicking the fail button:

Refused to apply style from 'http://localhost:8000/draft/linux/install-os-ubuntu/stylesheets/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

The reason seems that HTML is considered to be a real HTML. The browser looks for sources, fails and sends the error. But for my purpose this is just a string.

6PUGn.png

Could you help me understand why this situation occurs and cope with the problem of copying HTML documents.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值