<script type="text/javascript"> function copyUrl2() { var oInput = document.createElement('input');//创建input oInput.value = "12345566666393494"; document.body.appendChild(oInput);//挂在都dom节点 oInput.select(); //进入选中状态 document.execCommand("Copy"); // 执行浏览器复制命令 oInput.className = 'oInput'; oInput.style.display = 'none'; } </script> <input type="button" onClick="copyUrl2()" value="点击复制代码" />