JS copy text to the clipboard

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. QQ discussion groups: 271934368 https://blog.csdn.net/huangjp_hz/article/details/78521289
<textarea cols="20" rows="10" id="biao1">用户定义的代码区域</textarea>
<input type="button" onClick="copyUrl2()" value="点击复制代码" />

function copyUrl2()
{
    var Url2=document.getElementById("biao1");
    Url2.select(); // 选择对象
    document.execCommand("Copy"); // 执行浏览器复制命令
    alert("已复制好,可贴粘。");
}

Guess you like

Origin blog.csdn.net/huangjp_hz/article/details/78521289
Recommended