6
   

javascript copy and paste to clipboard

 
 
Reply Mon 5 Jul, 2004 08:09 pm
hi there!!
i need to know the script to copy and paste to clipboard.
Please help me!!!!
thanks.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 6 • Views: 47,731 • Replies: 13
No top replies

 
Craven de Kere
 
  1  
Reply Mon 5 Jul, 2004 11:58 pm
Copy script:

Code:<SCRIPT language="JavaScript">
<!--
function highlightmetasearch() {
document.post.message.select(); document.post.message.focus();
}
function copymetasearch() {
highlightmetasearch();
textRange = document.post.message.createTextRange();
textRange.execCommand("RemoveFormat");
textRange.execCommand("Copy");
alert("This post has been copied to your clipboard.\nIf this post is lost when you submit it you can easily repost it.\nAlways use this feature before posting! - \nwww.able2know.com");
}
// -->
</SCRIPT>


Make sure to change the alert's wording. Also change this line:

Code:textRange = document.post.message.createTextRange();


"post" should be the name of the form.

"message" should be the name of the textarea

Code: <script language="JavaScript" type="text/javascript">
<!--
if ((navigator.appName=="Microsoft Internet Explorer")&&(parseInt(navigator.appVersion)>=4)) {
document.write('<INPUT type="button" class="button" value="COPY TO CLIPBOARD" onClick="copymetasearch();">');
} else {
document.write('<INPUT type="button" class="button" value="HIGHLIGHT TEXT" onClick="highlightmetasearch();">');
}
// -->
</script>


The paste script:

Code:<script>

function a2kpaste() {
var rng = document.selection.createRange();
rng.execCommand("paste");
}
</script>


The button

Code:<input type="button" class="button" value="Paste" onclick="document.post.message.focus(); a2kpaste();">


Make sure to change the button to reflect the form and field names as well.
lindaz142
 
  1  
Reply Thu 8 Jul, 2004 08:08 pm
is there any other way to make the copied value being paste to the selected field without asking them to click ctrl-v ?
0 Replies
 
Craven de Kere
 
  1  
Reply Thu 8 Jul, 2004 08:09 pm
Yes, I provided the script above.
0 Replies
 
HimanshuJain
 
  1  
Reply Thu 16 Feb, 2006 10:41 pm
How to copy contents of a whole form to clipboard
Hi,

I am trying to design a form which will serve as a template for a particular report. What I want to do is on click of a button, the complete content of a form should be copied to clipboard including all labels, text areas, input fields etc?

Is this possible with Javascript?

Please try yo provide me a solution asap.

Regards
Himanshu
0 Replies
 
Craven de Kere
 
  1  
Reply Fri 17 Feb, 2006 07:02 pm
Re: How to copy contents of a whole form to clipboard
HimanshuJain wrote:

Is this possible with Javascript?


Yes, however it would be saved into a single text blob with delimiters as the clipboard doesn't have "fields".

The blob would then have to be parsed for reinsertion. It's possible but would be tricky.

Quote:

Please try yo provide me a solution asap.


It's a significant amount of work (I estimate that it's worth over $500 of development time) so I don't know if anyone will quickly do the work for you unless they need it themselves (I personally don't have time, whether I do it for free or not).

Basically I'm saying that it looks like you are expecting people to work for you for free, and that you may need to simply contract a js developer to do this for you.
0 Replies
 
HimanshuJain
 
  1  
Reply Tue 21 Feb, 2006 07:27 pm
Hi,
I didnot know that it will be this much work as I can see copy to clipboard scripts spread all over the web. Only I wanted to customise it.

So is it possibleto generate a report out of a form in a particular format.

Just seeking advice.

Regards,
Himanshu
0 Replies
 
Craven de Kere
 
  1  
Reply Mon 27 Feb, 2006 04:57 am
Yup, it's all possible, but it would likley require a script that is customized to a degree that the free ones out on the net won't be able to handle it.
0 Replies
 
BijonChandy
 
  1  
Reply Tue 30 Jan, 2007 09:01 am
Hi there !!

Is there some way we can check the text that is entered in a textbox (this one for example) for a particular string (say "chuck"), and then have a pre-determined formbox pop up, with a message (say "Sorry, please re-enter !" ) ?? This should happen when we click a button (for example, when we click "Preview" in this textbox)..

Will be a great help if you could pls give the code for this !!

Thanks..
0 Replies
 
newsn
 
  1  
Reply Sun 15 Apr, 2007 08:40 am
wonderful,i just need that script~
0 Replies
 
philsteels
 
  1  
Reply Sun 2 Aug, 2009 04:57 pm
This script is very useful, thank you.

I want to copy the contents of the clipboard directly to the screen output, rather than in a text box, so have written the following script:-

Code:<script type="text/javascript">
var clipboard = document.selection.createRange();
clipboard.execCommand("paste");
document.write(clipboard);
</script>


But all I get on screen is

[object]

Can anyone see what am i doing wrong?

Thanks in advance.
Phil.
0 Replies
 
gkumar
 
  1  
Reply Wed 19 Aug, 2009 01:08 am
@lindaz142,
I've been search the web for few weeks to see if Java can do one click copy and paste function to the clipboard and then I can just Ctrl-V the copied "texts." I initially got this idea when I began to approve hosting application. Instead of writing the same message over and over again, I decided to make me a page where I can simply copy the code to appropriate answers. And seems like my laziness is the mother of inventions laugh.gif Instead of doing Ctrl-A, Ctrl-C then Ctrl-V to the post board I started to dream about a button that will select my pre-written message and copy at the stroke of one single click.

I have search the web but they were either not working properly or it was way too long for me to understand and work it in with my own webpage. But accidentally I found this script that is short and does the job like no other I have ever seen. So I'd like to share it with you.
AnilReddyV
 
  1  
Reply Mon 30 May, 2011 05:42 am
@gkumar,
Could you please share the code with me,
Thanks,
Anil
0 Replies
 
guerciofernando
 
  0  
Reply Mon 29 Aug, 2011 12:29 am
@Craven de Kere,
This is nice information about scripting language java. I hope it will helpful.
0 Replies
 
 

Related Topics

In How much time a website can be developed? - Question by aussiejumpingcastle
Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » javascript copy and paste to clipboard
Copyright © 2019 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 10/17/2019 at 05:34:26