- Code: Select all
<script type="text/javascript">
<!--
function copyToClipboard( )
{
var objCopy = document.frmClipboard.txtComments;
Copied = objCopy.createTextRange( );
Copied.execCommand("RemoveFormat");
Copied.execCommand("Copy");
}
-->
</script>
- Code: Select all
<form name="frmClipvboard">
<textarea name="txtComments">This text is copied from GeoSourceCode.com</textarea>
</form>
<input type="button" value="Copy" onclick="copyToClipboard( )">
The script uses a lot of commands proprietary to Internet Explorer 4.0 and above. The function is named copyToClipboard(). It is triggered when the button is clicked. Next, the text (Copied) is copied to the clipboard using the IE execCommand to copy.