Loading...


bookmark - Copy To Clipboard Function

Copy To Clipboard Function

 
 Discussion by pbolduc with 6 Replies.
 Last Update: January 4, 2010, 9:48 am
 
bookmark - Copy To Clipboard Function  
Quickly Post to Copy To Clipboard Function  w/o signup Share Info about Copy To Clipboard Function  using Facebook, Twitter etc. email your friend about Copy To Clipboard Function Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

I know how to code to get the text in a text area highlighted, I was wondering if anyone could provide me with the code to copy the content of a text area directly to the clipboard.

Thanks in advance,

Pete










   Sat Dec 8, 2007    Reply         

A time ago i need a script to do this action, and after some searching i found how to do it. You say that you have the code that selects the content text of the textarea, so, simply add a button to your form which will perform the action of copying it to the clipboard when it is clicked and the following javascript function, you can place this function in an external javascript file or in the HEAD section of your page.

Here is the Javascript code:

CODE

function copy(text) {
if (window.clipboardData) {
window.clipboardData.setData("Text",text);
}
}

And the button:

CODE

<input type="button" value="Copy To Clipboard" onclick="copy(document.your_form_name.your_textarea_name.value);">

I'm not pretty sure but i guess that it only works with Internet Explorer 6, i don't test it with any other browser.

Check also this topic

Best regards,

   Sun Dec 9, 2007    Reply         

Thanks man...

sry I didn't thank you sooner but was on vacation

pete

   Wed Dec 19, 2007    Reply         


QUOTE (TavoxPeru)

A time ago i need a script to do this action, and after some searching i found how to do it. You say that you have the code that
.....
Link: view Post: 114933

Thanks!! I am just finding it! Javascript copy function! I wonder if it will notice user to press "OK"?

   Thu Dec 20, 2007    Reply         

QUOTE (pbolduc)

Thanks man...

sry I didn't thank you sooner but was on vacation

pete
Link: view Post: 115480

You are welcome, do you test it in Firefox????

Best regards,

   Thu Dec 20, 2007    Reply         

QUOTE (takashiro)

Thanks!! I am just finding it! Javascript copy function! I wonder if it will notice user to press "OK"?
Link: view Post: 115498

You are welcome, and the function will not notice the user to press "OK" or any other key.

Best regards,

   Thu Dec 20, 2007    Reply         


copy from excel and paste in web browserCopy To Clipboard FunctionHello,I need a code that copies the (selected single) row items from excel sheet to web browser's text area .-question by jitendra kumar

   Mon Jan 4, 2010    Reply         

Quickly Post to Copy To Clipboard Function  w/o signup Share Info about Copy To Clipboard Function  using Facebook, Twitter etc. email your friend about Copy To Clipboard Function Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Security Issue With Ctrl c copy On ...

hi friends, I posted the following security exploit in IE at Trap17 but missed out posting it here. Click here for the actual post: http://www.trap17.com/forums/security-issu...ard-t2 ...more

   14-Sep-2005    Reply         

One Click To Copy Script

As a project to "boilerplate" some text, I had this idea of making a couple of textareas in html and having a single click on the input button copy the contents to the clipboard and then pasting the text into another blank textarea. Several textareas would contain the different pieces of t ...more

   17-Feb-2007    Reply         

Writing Functions In PHP

Well, it has been a while since I offered a tutorial here at AstaHost. Most of my creativity has gone toward my new website, Handy PHP. The website is just getting started and it is hard to post potential content for my website here instead of there. ...more

   20-Mar-2007    Reply         

Fun With Javascript And Forms Lets have some fun with javascript!   Fun With Javascript And Forms Lets have some fun with javascript! (2) (1) When A User Close The Browser Window How to control this action  When A User Close The Browser Window How to control this action