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

javascript click and copy

P: 10
is there any way to add event to the mozilla firefox where the selected text is copied into clipboard with jus a click.. its like u click on the text and the text is selcted , the selected text has to be copied to the clipboard with a just a click rather than using ctr+c ????
Oct 1 '08 #1
Share this Question
Share on Google+
6 Replies


Plater
Expert 5K+
P: 7,872
Well javascript can do that. I will move your question there.
MODERATOR
Oct 1 '08 #2

acoder
Expert Mod 15k+
P: 16,027
This won't be possible unless you have privileges and the user allows them too.

Is this for the Web?
Oct 1 '08 #3

Plater
Expert 5K+
P: 7,872
This won't be possible unless you have privileges and the user allows them too.

Is this for the Web?
You need special privledges for javascript to access your clipboard?

http://www.google.com/search?source=...ript+clipboard
Oct 1 '08 #4

acoder
Expert Mod 15k+
P: 16,027

gits
Expert Mod 5K+
P: 5,235
yes ... thanks god ;) ... sometimes i really don't want someone to read my clipboard ... for example i would have copied email-addresses or other sensitive information to it and in case a webpage could just grab it it would be a serious security-issue ...

kind regards
Oct 1 '08 #6

rnd me
Expert 100+
P: 427
there are workarounds.

flash can do it, and likely from a hidden frame.

as long as flash as enabled, i wouldn't fee too safe,

i noticed a site that had a button that said "place on clipboard".
i laughed and clicked it.
the joke was on me when i got to notepad.

EDIT:

here is working code i cleaned up for firefox:


Expand|Select|Wrap|Line Numbers
  1.  
  2. function copy(str) {
  3.    var D=document;
  4.     if(!copy.div) { copy.div = D.createElement('div'); D.body.appendChild(copy.div);  }
  5.  
  6. flashVar = "Q1dTB3kAAAB4nKtgYI1nYOBfwMDAw8jgzPT//3975lAGBoYOdQYWhu\
  7. SczIKk/MSiFIac1Lz0kgyG4MriktRchuLUEme41DQmBg4GGRDJ6Cc0l4lBAibCzsDO\
  8. CDSJgwksyRwkzuAA5AIAd7oY/w==";
  9.  
  10. copy.div.innerHTML =  '<embed src="'+flashVar+'" FlashVars="clipboard='+encodeURIComponent(str) +
  11.     '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
  12. }
  13.  
  14.  
it cannot read the clipboard, so i don't feel too bad about posting it.
Oct 1 '08 #7

Post your reply

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