I really appreciate this, as I had to jump through a lot of loops to do so a few years ago. But I think that the browser should display a small alert when this API is called (like the webcam, or microphone).
> Google Chrome and Internet Explorer both also support this API. Chrome uses
> the same restriction as Firefox (that it must be run in a user-initiated
> callback). Internet Explorer allows it to be called at any time, except it
> first prompts the user with a dialog, asking for permission to access the
> clipboard.
I was so disappointed that every color picker website nowadays uses flash/zeroclipboard to only copy HEX color value (6 letters!). It's so slow and inefficient. I ended up making my own one using this clipboard API - http://0xrgb.com
I consider it an OS-level deficiency that clipboard copy is destructive by default. The fact that no major OS has multi-clipboard out of the box in 2015 is shameful.
I don't mind sites being able to send data to the clipboard, as long as 1) they have explicit permission, and 2) they can only do so in response to a user action.
Anything involving modal dialogs is bad UX these days, especially considering the variety of platforms web code needs to run on. You don't have "CTRL+C" on a smartphone or tablet.
I make a text editor that runs in a texture on a 3D object in the browser. I have a text area hidden in the background that technically holds focus and all clipboard operations go through it.
I was hoping this would let me get rid of that crufty text area. It's a serious quality and performance liability, and in certain special cases even ruins the UX. But it looks like that is not the case. Le sigh.
The execCommand("cut"/"copy") API is only available during a user-triggered callback, such as a click. If you try to call it at a different time, execCommand will return false, meaning that the command failed to execute.
Couldn't you bypass this by creating an invisible button, and then simulating a click event?
If they do it right, I imagine the source of the event would be tainted, so that only an actual click received from the OS would be allowed to propagate through.
I'm sure it's tricky to ensure this, though. Like pop-up blocking.
Simulated click events are tracked as simulated. From the Javascript point of view there's not much difference unless synthetic/authentic click activation is involved (i.e. links, form submit, etc)
Websites should not be able to overwrite the clipboard unless the action is user-initiated, from the blog post: The execCommand("cut"/"copy") API is only available during a user-triggered callback, such as a click. If you try to call it at a different time, execCommand will return false, meaning that the command failed to execute.
Thank you developers and all, but I don't think I had much trouble copying text before. On the contrary, when I click on a field and it force select everything for me I get frustrated.
Trust me, selecting text is not a problem. I haven't seen a place where click to select was a life savior.
[+] [-] Raed667|10 years ago|reply
[+] [-] steveklabnik|10 years ago|reply
[+] [-] artursapek|10 years ago|reply
http://stackoverflow.com/questions/14472526/will-there-ever-...
[+] [-] zserge|10 years ago|reply
Glad to see that FF now supports this API, too!
[+] [-] ck2|10 years ago|reply
I guess I could put a megabytes into anyone's clipboard now when they click on any link on a website.
[+] [-] M4v3R|10 years ago|reply
[+] [-] tyho|10 years ago|reply
[+] [-] lukifer|10 years ago|reply
[+] [-] JoshTriplett|10 years ago|reply
[+] [-] moron4hire|10 years ago|reply
[+] [-] y0ghur7_xxx|10 years ago|reply
[+] [-] moron4hire|10 years ago|reply
I was hoping this would let me get rid of that crufty text area. It's a serious quality and performance liability, and in certain special cases even ruins the UX. But it looks like that is not the case. Le sigh.
[+] [-] ihuman|10 years ago|reply
Couldn't you bypass this by creating an invisible button, and then simulating a click event?
[+] [-] function_seven|10 years ago|reply
I'm sure it's tricky to ensure this, though. Like pop-up blocking.
[+] [-] mschuster91|10 years ago|reply
[+] [-] Manishearth|10 years ago|reply
[+] [-] ck2|10 years ago|reply
[+] [-] Vexs|10 years ago|reply
[+] [-] rhelmer|10 years ago|reply
[+] [-] ibrad|10 years ago|reply
Trust me, selecting text is not a problem. I haven't seen a place where click to select was a life savior.