Jump to content
xisto Community
pbolduc

Copy To Clipboard Function

Recommended Posts

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

Share this post


Link to post
Share on other sites

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:

function copy(text) {  if (window.clipboardData) {	window.clipboardData.setData("Text",text);  }}
And the button:
<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 One Click To Copy Script, Works in IE6 but not any other Browsers

Best regards,
Edited by TavoxPeru (see edit history)

Share this post


Link to post
Share on other sites

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

pete

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

Best regards,

Share this post


Link to post
Share on other sites

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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.