improvement:改进复制功能增加兼容性
This commit is contained in:
parent
3d9cf6aa07
commit
e9e9d95ec6
|
@ -25,7 +25,18 @@ async function init() {
|
|||
const textToCopy = [
|
||||
...new Set(spans.map((span) => span.textContent)),
|
||||
].join("");
|
||||
navigator.clipboard.writeText(textToCopy);
|
||||
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(textToCopy);
|
||||
} else {
|
||||
const textarea = document.createElement("textarea");
|
||||
textarea.value = textToCopy;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
|
||||
console.log(textToCopy);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user