Home > Article > Web Front-end > Use of javascript copy and paste and clipboardData_javascript skills
window.clipboardData can realize copy and paste operations, its getData method can realize data reading, and the setData method can realize data setting
<script language="javascript"> function readTxt() { alert(window.clipboardData.getData("text")); } function setTxt() { var t=document.getElementById("txt"); t.select(); window.clipboardData.setData('text',t.createTextRange().text); } </script> <input name="txt" value="测试"> <input type="button" value="复制" onclick="setTxt()"> <input type="button" value="读取" onclick="readTxt()">