本文主要和大家分享js復(fù)制文本內(nèi)容到剪切板實現(xiàn)代碼,希望能幫助到大家。
兼容主流瀏覽器
<script type="text/javascript"> function copyUrl2() { var Url2=document.getElementById("biao1").innerText; var oInput = document.createElement('input'); oInput.value = Url2; document.body.appendChild(oInput); oInput.select(); // 選擇對象 document.execCommand("Copy"); // 執(zhí)行瀏覽器復(fù)制命令 oInput.className = 'oInput'; oInput.style.display='none'; alert('復(fù)制成功'); } </script> <p cols="20" id="biao1">12345678</p> <input type="button" onClick="copyUrl2()" value="點擊復(fù)制代碼" />
相關(guān)推薦:
JS復(fù)制內(nèi)容到剪切板的實例代碼(兼容IE與火狐)_javascript技巧
以上就是js復(fù)制文本內(nèi)容到剪切板實現(xiàn)代碼的詳細(xì)內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章!