js复制URL链接
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