Results 1 to 4 of 4

Thread: Code to copy to clipboard

  1. #1
    Join Date
    May 2008
    Posts
    222

    Code to copy to clipboard

    Hi friends
    I have some hands on experience in java script now. I have even done some small programs in java script. But I was wondering that I could create a program that copies something to my clipboard. I mean a simple program that copies something to the clipboard on pressing a button. Further I want to echo the value into a hidden form input field. So, my question is how can the value be copied in the clipboard. Any help or advice will be appreciated. Thanks in advance.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Code to copy to clipboard

    Hello
    I wrote a code something close to what you were saying, I think this can be achieved from the code I have posted below. Just go through it. It may help you. Any more problem do post back.
    Code:
     function copyToClipboard(s)
          {
          if( window.clipboardData && clipboardData.setData )
          {
          clipboardData.setData("Text", s);
          }
          }

  3. #3
    Join Date
    May 2008
    Posts
    222

    Re: Code to copy to clipboard

    Hi
    Thanks for your reply and thanks for you code. But unfortunately I must say that the code does not work for me. It is giving an error and I can not even guess what the error is all about. I think there is a problem in this par tof the code.
    Code:
    if( window.clipboardData && clipboardData.setData )
          {
          clipboardData.setData("Text", s);
          }
    Pleas if you check again and post me back a more proper code. Thanks

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Code to copy to clipboard

    Hi
    I will definitely post a code back, but before that it would be great if you post your code in there. so that we can see where exactly is the problem and what is the error in the program. Unfortunately you have not posted the code yet, still you can try writing this statement to your code document.execCommand as follows
    Code:
          document.execCommand("copy",false,text)
    If it works let me know.

Similar Threads

  1. Windows 7: ctrl+C cannot copy onto the clipboard
    By The!Winston in forum Operating Systems
    Replies: 5
    Last Post: 02-12-2010, 07:44 AM
  2. Applescript to Copy from Clipboard to Terminal
    By Jensen Ackles in forum Operating Systems
    Replies: 6
    Last Post: 31-07-2010, 06:05 AM
  3. Copy Gantt chart to clipboard
    By !Starr! in forum Microsoft Project
    Replies: 3
    Last Post: 20-04-2010, 08:00 AM
  4. Not able to Copy in Clipboard using VBScript
    By Pratim in forum Software Development
    Replies: 5
    Last Post: 27-01-2010, 07:34 PM
  5. Copy/Paste/Clipboard Prob
    By Nadeem in forum Windows XP Support
    Replies: 3
    Last Post: 13-09-2009, 08:16 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,670,276.44920 seconds with 17 queries