按钮一键复制链接

  <tr>
          <th>推荐链接:</th><td><input name="invite" type="text" pattern='required' class="normal" value=
          'http://ll.webshop' id="bt"/><label class="btn"><input type="submit" value="我要推荐" onclick="copyurl()" /></label></td>
 </tr>

<script type="text/javascript">
  function copyurl()
  {
    var Url2=document.getElementById("bt");
    Url2.select(); // 选择对象

    document.execCommand("Copy");
    alert("已复制,可贴粘。");
    //复制链接自动跳转
    //location.href="{$invate_str}";
  }
 </script>

原文地址:https://www.cnblogs.com/shaohuixia/p/5488151.html