先上代码。
- <a href="javascript:;" onclick="copyText()">点击复制链接</a> <script> function copyText() { var text = "https://www.honghuangwenxue.com/buluo-$_G[tid]-1-1.html"; var input = document.createElement("textarea"); input.style.position = 'fixed'; input.style.top = 0; input.style.left = 0; input.value = text; document.body.appendChild(input); input.select(); document.execCommand("copy"); alert("复制地址成功,现在可以粘贴到任意地方!"); document.body.removeChild(input); return false; } </script>
复制代码
上面的代码实现了点击复制链接以后弹窗提示,效果是这样:
[attach]51208[/attach]
弹窗中带网站地址,我是想不要地址,大概效果是这样:
[attach]51209[/attach]
1 贡献
最佳答案
DZ自己就带复制的内容的JS函数的
比如
- <a href="javascript:;" onclick="setCopy('https://www.kuozhan.net', '推广链接复制成功');" >复制</a>
复制代码效果如图:
[attach]51210[/attach]
[attach]51211[/attach]湖中沉发表于1 小时前
- 详细答案 >