天天看点

点击复制文字分享到微信群

<style type="text/css">
   .wrapper {position: relative;}
   #input {position: absolute;top: 0;left: 0;opacity: 0;z-index: -10;}
</style>

<div class="wrapper">
   <p id="text" style="display:none">http://218.205.36.78:8086[!--titleurl--]</p>
   <textarea id="input">搞笑了</textarea>
   <button onclick="copyText()">点击复制网址分享到微信群</button>
</div>
<script type="text/javascript">
    function copyText() {
      var text = document.getElementById("text").innerText;
      var input = document.getElementById("input");
      input.value = text; // 修改文本框的内容
      input.select(); // 选中文本
      document.execCommand("copy"); // 执行浏览器复制命令
      alert("复制成功");
     location.href="weixin://" target="_blank" rel="external nofollow" ;
    }
  </script>
           

继续阅读