JS点击复制到剪切板

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
  <input type="text" value="用户定义的代码区域" id="biao1" />
  <input type="button" onClick="copyUrl2()" value="点击复制代码" />
</body>
<script type="text/javascript">
  function copyUrl2(){
    var Url2=document.getElementById("biao1");
    Url2.select(); // 选择对象     document.execCommand("Copy"); // 执行浏览器复制命令     alert("已复制好,可贴粘。");
  }
</script> </html>

 

posted @ 2017-09-28 20:57  Tim.Arrow  阅读(418)  评论(0编辑  收藏  举报