浏览代码

Better way

Piotr Czajkowski 1 周之前
父节点
当前提交
bffa515c5b
共有 1 个文件被更改,包括 5 次插入 和 3 次删除
  1. 5 3
      html/result.html

+ 5 - 3
html/result.html

@@ -22,10 +22,12 @@
 			function copyLink() {
   				const copyText = document.getElementById("link");
   				copyText.select();
-  				document.execCommand("copy");
+				navigator.clipboard.writeText(copyText.value)
+				    .then(() => info.textContent = "Copied!")
+				    .catch(err => console.error(err));
 
-				let info = document.getElementById("info");
-				info.textContent = "Copied!";
+				//let info = document.getElementById("info");
+				//info.textContent = "Copied!";
 }
 		</script>