2

I have seen a few threads explaining that Flash can be used to set the clipboard data in Mozilla and Internet Explorer, it's easy, etc.

For example Greasemonkey\JavaScript Copy to Clipboard button

However, I would like to read the clipboard and remove certain items before setting it. Is there any way to do this?

So.. Is it possible then to detect whether copying and pasting is occuring? Then redirect them to another URL?

Community
  • 1
  • 1
Ke.
  • 2,484
  • 8
  • 40
  • 78
  • 2
    Consider the scenario where the user just copied their login password to some secure service into their clipboard and then they haplessly visit a malicious site that uses JavaScript to harvest their clipboard and an AJAX request to send it off to the server. Major security risk. – Nathan Taylor Feb 26 '10 at 16:51
  • i guess it is a security issue for someone who copies and pastes their password, but im not after this info. My question is can it be done? – Ke. Feb 26 '10 at 16:54
  • Is it possible then to detect whether copying and pasting is occuring? Then redirect them to another URL? – Ke. Feb 26 '10 at 16:57
  • 1
    However you do this, be sure that you don't wipe the user's clipboard without permission. Provide a Copy/Paste button that calls your action. e.g. GitHub has a little copy button for the read-only url that uses a hidden flash component. – scunliffe Feb 26 '10 at 17:05
  • 1
    If you're afraid of someone stealing the content by copying a url of some sort, maybe you shouldn't put it on the internet to begin with. – Alex Sexton Feb 26 '10 at 17:06

1 Answers1

5

Reading the clipboard is a pretty big security issue. Even if you can do it, it's not considered a friendly tactic, and I would advise against it, especially if you plan on changing it.

Alex Sexton
  • 10,401
  • 2
  • 29
  • 41
  • 3
    +1 — IE is the only browser I know of that ever let you do this, and I think even they are backing away from it now. – Robusto Feb 26 '10 at 16:52
  • yep i realise this, i guess its a subjective thing. I want to replace one character if someone copies my url. – Ke. Feb 26 '10 at 16:52
  • then how come the script above allows you to set the clipboard in mozilla? – Ke. Feb 26 '10 at 16:53
  • 2
    It uses flash - there isn't a solution for this in javascript. That's what the chosen answer says in the first sentence. If someone wants to copy your url, they should be able to, that's how computers work. – Alex Sexton Feb 26 '10 at 16:59