By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,750 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,750 IT Pros & Developers. It's quick & easy.

[JavaScript]How to "auto" copy content of textbox to clipboard

100+
P: 121
I am doing a ASP.NET porject, inside a asp control tag there are some textboxes for users to input data.

Later they can take previously entered data out of those textboxes.

To provide better UI efficiency, I would like to use JavaScripts to support "auto" copy to clipboard, but I don't know how to achieve that?

Here is my code stub:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     var input = document.getElementById("<%=txtUser.ClientID%>").text;
  3.     function autocopy(input)
  4.     {
  5.         //it should pass input to windows clipboard, or any program
  6.         // that can support the "ctrl+V" feature...
  7.     }
  8. </script>
I am quite a noob at javascript, so I really have no idea how to continue.

Thanks in advance!
Apr 3 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
In IE, you can use something like:
Expand|Select|Wrap|Line Numbers
  1. window.clipboardData.setData("text",...);
In Firefox, you will need to sign the script or allow it to run - see link. I'm not sure about other browsers.
Apr 3 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.