<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系統)依舊存在問題