Cut ,Copy and Paste Clipboard Text with JavaScript

<script type="text/javascript">
function CopyToClipboard()
{
CopiedTxt = document.selection.createRange();
CopiedTxt.execCommand("Copy");
}

function PasteFromClipboard()
{
document.Form1.txtArea.focus();
PastedText = document.Form1.txtArea.createTextRange();
PastedText.execCommand("Paste");
}

function CutToClipboard()
{
CutTxt = document.selection.createRange();
CutTxt.execCommand("Cut");
}

</script>

<form name="Form1">
Select this text, copy it using the copy button, and paste it below.<br /><br />
<textarea id="txtArea" cols="60" rows="5"></textarea>
<br />
<input type="button" onClick="CutToClipboard()" value="Cut to clipboard" />
<input type="button" onClick="CopyToClipboard()" value="Copy to clipboard" />
<input type="button" onClick="PasteFromClipboard()" value="Paste from clipboard" />
</form>


Source:http://www.geekpedia.com/tutorial126_Clipboard-cut-copy-and-paste-with-JavaScript.html

0 comments for this post

Post a Comment

Blog Widget by LinkWithin