js一鍵複製並調起微信客戶端

<div>
    <input type="text" id="tid" name="tid" value="要複製的內容" readonly="readonly">
    <p class="btn" onclick="copyUrl()">一鍵複製並打開微信</p>
</div>
<script> 
    function copyUrl(){
        var input = document.getElementById("tid");
        input.select();
        input.setSelectionRange(0, input.value.length), document.execCommand('Copy');
        var locatUrl = "weixin://";
        if (/ipad|iphone|mac/i.test(navigator.userAgent)) {
            var ifr = document.createElement("iframe");
            ifr.src = locatUrl;
            ifr.style.display = "none";
            document.body.appendChild(ifr);
        }else{
              window.location.href = locatUrl;
        }
    }
</script>

蘋果5S手機(8.4.1系統)依舊存在問題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章