Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"copy to clipboard" doesn't work

 
Mike Blaszczak
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "Copy to clipboard" link on CODE blocks doesn't appear to work in Firefox 23, but works fine in IE 10. When I try to use the feature in FireFox 23, I get a popup saying that "the code is in your clipboard now", but my clipboard is unchanged. Is there some setting I must change in order to have this feature work correctly?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most browsers actively work to block interaction with the clipboard from JavaScript, and don't provide a setting to allow it. There's a workaround that uses Flash, but lots of users block that these days, too. As you observe, Internet Explorer does not block much of anything.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to explicitly allow JavaScript to do this, since it's a major security issue. Here's how to do it for Firefox.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49443
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I usually use the “view plain” link: that opens the code in a sub‑window and you can easily copy or drag and drop thence.
 
Mike Blaszczak
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the security issue?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64978
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replacing the value that a user thinks is in the clipboard (whatever they've cut last) with something else is a vector for social engineering malware attacks. It's a weak one; but one nevertheless.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allowing JavaScript to access the clipboard means that a malicious web site can get at your credit card information - if you happen to access that site right after you had that in your clipboard. Unless you keep track of what you have on clipboard any time you surf the web, I'd suggest it's a good idea to leave that turned off.
 
Mike Blaszczak
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Allowing JavaScript to access the clipboard means that a malicious web site can get at your credit card information - if you happen to access that site right after you had that in your clipboard. Unless you keep track of what you have on clipboard any time you surf the web, I'd suggest it's a good idea to leave that turned off.
That seems to be an issue about reading the clipboard; this feature writes to the clipboard.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64978
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you not read my reply?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Blaszczak wrote:That seems to be an issue about reading the clipboard; this feature writes to the clipboard.

Correct. So it depends on how finegrained the security settings are - whether any given browser allows read and write access to be enabled separately.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic