Copy to Clipboard

This section contains a lot of Scripting material for your website.

Copy to Clipboard

Postby Web Guru on April 7th, 2008, 4:56 am

Note: This code only works for Internet Explorer.

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.
User avatar
Web Guru
 
Posts: 66
Joined: March 24th, 2008, 7:59 am
Location: Lahore, Pakistan

Return to Java Script / VB Script

Who is online

Users browsing this forum: No registered users and 0 guests