Javascript copy and paste with the use of clipboardData


Window.clipboarddata can be used to copy and paste, its getData method can be used to read data, and setData method can be used to setData

 <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()">