【发布时间】:2020-10-18 06:42:05
【问题描述】:
如何成功地将本页的 SVG 内容复制到剪贴板?
select() 方法出现如下错误:
Uncaught TypeError: el.select is not a function
at <anonymous>:1:4
这是我目前可以在控制台中运行的代码。
function copyClip() {
const docEl = document.documentElement
const string = new XMLSerializer().serializeToString(docEl)
const el = document.createElement('textarea')
docEl.insertAdjacentElement('beforeend', el)
el.value = string
el.select()
document.execCommand('copy')
}
copyClip()
【问题讨论】:
-
如果您也提供一点信息,您希望如何回答?请阅读:stackoverflow.com/help/minimal-reproducible-example
标签: javascript xml svg clipboard