Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Copying to clipboard

Reply
Thread Tools

Copying to clipboard

 
 
Butterfly Bill
Guest
Posts: n/a
 
      10-29-2009
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
 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      10-29-2009
Butterfly Bill wrote:
> 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.
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      10-29-2009
VK wrote on 29 okt 2009 in comp.lang.javascript:

> Butterfly Bill wrote:
>> 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.


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>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Butterfly Bill
Guest
Posts: n/a
 
      10-29-2009
On Oct 29, 12:38*am, VK <(E-Mail Removed)> wrote:
> Butterfly Bill wrote:
> > 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.



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?
 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      10-29-2009
Butterfly Bill wrote:
> 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?

 
Reply With Quote
 
Chuck Anderson
Guest
Posts: n/a
 
      10-29-2009
Butterfly Bill wrote:
> On Oct 29, 12:38 am, VK <(E-Mail Removed)> wrote:
>
>> Butterfly Bill wrote:
>>
>>> 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.
>>

>
>
> 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
*****************************
 
Reply With Quote
 
Butterfly Bill
Guest
Posts: n/a
 
      10-29-2009
On Oct 29, 11:47*am, VK <(E-Mail Removed)> wrote:
> Butterfly Bill wrote:
> > 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?


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.
 
Reply With Quote
 
Butterfly Bill
Guest
Posts: n/a
 
      10-29-2009
On Oct 29, 1:56*pm, Butterfly Bill <(E-Mail Removed)>
wrote:
> On Oct 29, 11:47*am, VK <(E-Mail Removed)> wrote:
>
> > Butterfly Bill wrote:


> 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()
 
Reply With Quote
 
Boris Schaeling
Guest
Posts: n/a
 
      10-30-2009
On Thu, 29 Oct 2009 06:20:58 +0100, Butterfly Bill
<(E-Mail Removed)> wrote:

> 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?


I happen to read about Zero Clipboard yesterday which uses an invisible
Flash object to copy data: http://code.google.com/p/zeroclipboard/

Boris
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clipboard - Copy Image To Clipboard Mahsha Javascript 1 06-01-2009 05:06 PM
$clipboard = Gtk::Clipboard.get('PRIMARY')... under windows Dan Bishop Ruby 0 08-26-2008 01:47 PM
clipboard.setContents destroys clipboard.getContents? spunibard@gmail.com Java 2 03-02-2007 07:52 PM
Paste from clipboard when clipboard changes mid script melvynm@gmail.com Javascript 4 12-14-2004 10:59 PM
Using VB.Net or C#, utilizing the clipboard object, how to copy an MS Excel graphic from the clipboard to an image control and obtain its source reference TC ASP .Net 5 09-01-2004 04:49 AM



Advertisments