Copying to clipboard

B

Butterfly Bill

Is it possible, using javascript, to copy the current contents of a
text input box to the user's own computer's clipboard with a button or
a link?

-Bill
 
V

VK

Butterfly said:
Is it possible, using javascript, to copy the current contents of a
text input box to the user's own computer's clipboard with a button or
a link?

Cross-browser within the default security settings: no, it is not
possible.
 
E

Evertjan.

VK wrote on 29 okt 2009 in comp.lang.javascript:
Cross-browser within the default security settings: no, it is not
possible.

However IE still does not mind:

<script type='text/javascript'>

function copy(myText) {
if (window.clipboardData) {
window.clipboardData.setData('Text',myText);
};
};

copy('Hello world!');

</script>
 
B

Butterfly Bill

Cross-browser within the default security settings: no, it is not
possible.


Is it possible to make the document.forms.myname.value= data that
appears in the input window appear selected (with the black box around
it) so that the user can manually copy it?
 
V

VK

Butterfly said:
Is it possible to make the document.forms.myname.value= data that
appears in the input window appear selected (with the black box around
it) so that the user can manually copy it?

I'm afraid I didn't understand this sentence. Do you want to make a
page search tool like user typing in a word in a form field and the
occurrences of this word get selected in the page content? Something
else?
 
C

Chuck Anderson

Butterfly said:
Is it possible to make the document.forms.myname.value= data that
appears in the input window appear selected (with the black box around
it) so that the user can manually copy it?

I think you are looking for the select() function.

document.forms.myname.select();

--
*****************************
Chuck Anderson • Boulder, CO
http://www.cycletourist.com
Turn Off, Tune Out, Drop In
*****************************
 
B

Butterfly Bill

I'm afraid I didn't understand this sentence. Do you want to make a
page search tool like user typing in a word in a form field and the
occurrences of this word get selected in the page content? Something
else?

I am making a nonsense word generator and I am displaying the results
in what is normally used as an form input text box, and I want to be
able to copy them into Notebook or a word processor program. Yes, I
can sweep my mouse over the box and press Ctrl+C, but I would also
like to be able to push a button on the page to select it.
 
B

Butterfly Bill

I am making a nonsense word generator and I am displaying the results
in what is normally used as an form input text box, and I want to be
able to copy them into Notebook or a word processor program. Yes, I
can sweep my mouse over the box and press Ctrl+C, but I would also
like to be able to push a button on the page to select it.

What worked was using:
document.getElementById("myText").select()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top