From 15d33fd7591007d16458d0e5d3ae601e0d91d5f1 Mon Sep 17 00:00:00 2001 From: Ember Date: Tue, 2 Jul 2024 20:05:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=95=E7=A8=BF=E9=A1=B5?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E4=B8=8D=E8=83=BD=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- submission/index.html | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/submission/index.html b/submission/index.html index 9204919..8ff9693 100644 --- a/submission/index.html +++ b/submission/index.html @@ -637,16 +637,28 @@ markdown 基本语法教程 空格与换行 markdown 语法对于空格与换行 } } - // 复制HTML标签到剪贴板 - function copyImageUrl() { - const imageTag = document.getElementById("imageUrl").innerText; - navigator.clipboard.writeText(imageTag).then(() => { - alert("标签已复制到剪贴板!请直接粘贴到 markdown 编辑区中,并根据预览效果调整大小。"); - }, (err) => { - alert("复制失败!", err); - }); +// 复制HTML标签到剪贴板 +function copyImageUrl() { + const imageTag = document.getElementById("imageUrl").innerText; + // 创建一个临时文本区域元素 + const textArea = document.createElement("textarea"); + textArea.value = imageTag; + document.body.appendChild(textArea); + textArea.select(); + + try { + const successful = document.execCommand('copy'); + const msg = successful ? '标签已复制到剪贴板!请直接粘贴到 markdown 编辑区中,并根据预览效果调整大小。' : '复制失败!'; + alert(msg); + } catch (err) { + alert("复制失败!", err); } + document.body.removeChild(textArea); +} + + + document.getElementById('SubmitButton').onclick = function() { // 获取输入的值 const section = document.getElementById('section').value;