471,852 Members | 815 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,852 software developers and data experts.

javascript click and copy

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
6 2191
Plater
7,872 Expert 4TB
Well javascript can do that. I will move your question there.
MODERATOR
Oct 1 '08 #2
acoder
16,027 Expert Mod 8TB
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
7,872 Expert 4TB
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
16,027 Expert Mod 8TB
Yes - Granting JavaScript access to the clipboard.
Oct 1 '08 #5
gits
5,390 Expert Mod 4TB
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
427 Expert 256MB
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.

Similar topics

9 posts views Thread by Sarah | last post: by
9 posts views Thread by bert76 | last post: by
2 posts views Thread by Joe Fallon | last post: by
4 posts views Thread by bboyle18 | last post: by
24 posts views Thread by firstcustomer | last post: by
5 posts views Thread by Newbie Coder | last post: by
1 post views Thread by Thom.Burnett | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.