iwin9999

html:

<div style="height:0px; text-indent:-10000px;"><span id="hdcopyurl" style="">http://www.baidu.com</span></div>
<a onClick="copyUrl()" style="cursor: pointer;">复制链接</a>

js:

<script>

function copyUrl() {
var clipBoardContent = document.getElementById("hdcopyurl");
window.getSelection().selectAllChildren(clipBoardContent);
document.execCommand("Copy");
alert(\'复制成功\');
}

</script>

 

参考:https://www.cnblogs.com/MythLeige/p/9110621.html

分类:

技术点:

相关文章:

  • 2021-11-13
  • 2021-11-23
  • 2021-11-23
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-23
  • 2021-11-23
  • 2021-11-23
  • 2022-01-01
  • 2022-12-23
  • 2021-11-23
  • 2021-11-23
相关资源
相似解决方案