How do I create a "copy text" button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am building a site that provides a template that is supposed to be copied
and pasted into another application. I would like to add a button that would
do that for the user. If possible, I would prefer it if the user had to
click on just 1 button, have the desired text copied in the background and
not let them leave the home page. My needs require that I copy the desired
text to the clipboard. Any ideas you might have would be great.
 
r0b3rtw said:
I am building a site that provides a template that is supposed to be
copied and pasted into another application. I would like to add a
button that would do that for the user. If possible, I would prefer
it if the user had to click on just 1 button, have the desired text
copied in the background and not let them leave the home page. My
needs require that I copy the desired text to the clipboard. Any
ideas you might have would be great.


Have a look at The JavaScript Source
An example:
http://nl.internet.com/c.html?rtr=on&s=1,2er4,1,dad6,8xz2,400o,74e4

They do it like this;

<p>
Simply click inside the window below, use your cursor to highlight the
script, and copy [Control]+C the script into a new file in your text editor
(such as Note Pad) and save [Control+S]. The script is yours!!!</p>

<form NAME="copy">

<DIV align="center">
<input type=button value="Highlight All"
onClick="javascript:this.form.txt.focus();this.form.txt.select();">
</DIV>

<textarea NAME="txt" ROWS=20 COLS=75 WRAP=VIRTUAL>
text here
</textarea>

</form>

Clicking on the button selects the contents of the textarea.
 
Andrew said:
[O.P snipped]
Trevor, what has "drop down menus" (which is what that link you gave
points to) got to do with "copy text" buttons - as per the OP's
question?

The OP's question was how to set up a "copy text" button.

What I referred was an example on The Javascript Source of a script which
could be copied with such a button.

It just so happens that the script is for a drop-down menu. But the point
was that when you look at the reference, it contains code to copy the text
for that script. The actual contents of the script is irrelevant in this
case.

It could just as easily have been:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut
wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure
dolor in hendrerit in vulputate velit esse molestie consequat, vel illum
dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te
feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option
congue nihil imperdiet doming id quod mazim placerat facer possim assum.
Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum
claritatem. Investigationes demonstraverunt lectores legere me lius quod ii
legunt saepius. Claritas est etiam processus dynamicus, qui sequitur
mutationem consuetudium lectorum. Mirum est notare quam littera gothica,
quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis
per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis
videntur parum clari, fiant sollemnes in futurum.

I hope that is clearer
 
Yes I realised you were referring to the method that site gives the user to
copy the source code of their scripts - after I posted it - I was about to
suggest that myself....sorry, didn't read your reply properly.


Trevor L. said:
Andrew said:
[O.P snipped]
Trevor, what has "drop down menus" (which is what that link you gave
points to) got to do with "copy text" buttons - as per the OP's
question?

The OP's question was how to set up a "copy text" button.

What I referred was an example on The Javascript Source of a script which
could be copied with such a button.

It just so happens that the script is for a drop-down menu. But the point
was that when you look at the reference, it contains code to copy the text
for that script. The actual contents of the script is irrelevant in this
case.

It could just as easily have been:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut
wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum
iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel
illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto
odio dignissim qui blandit praesent luptatum zzril delenit augue duis
dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis
eleifend option congue nihil imperdiet doming id quod mazim placerat facer
possim assum. Typi non habent claritatem insitam; est usus legentis in iis
qui facit eorum claritatem. Investigationes demonstraverunt lectores
legere me lius quod ii legunt saepius. Claritas est etiam processus
dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare
quam littera gothica, quam nunc putamus parum claram, anteposuerit
litterarum formas humanitatis per seacula quarta decima et quinta decima.
Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in
futurum.

I hope that is clearer
 
Andrew said:
Yes I realised you were referring to the method that site gives the
user to copy the source code of their scripts - after I posted it - I
was about to suggest that myself....sorry, didn't read your reply
properly.

Thanks Andrew and God Bless
 
Back
Top