This article describes the method of implementing copy and pasting operations in JavaScript. Share it for your reference.
The specific implementation method is as follows:
Copy the code as follows:<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="test">
<input type="button" value="Copy" onclick="setTxt()">
<input type="button" value="read" onclick="readTxt()">
I hope this article will be helpful to everyone's JavaScript programming.