167 points · by smacktoward · 11y ago · 58 comments
> 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.
Seems like IE does what you want.It makes me feel very confused that this is actually true.
http://stackoverflow.com/questions/14472526/will-there-ever-...
Glad to see that FF now supports this API, too!
I guess I could put a megabytes into anyone's clipboard now when they click on any link on a website.
By "fails" - you mean it doesn't select/highlight the color string, nor it does copy it to clipboard?
window.prompt("Press Ctrl-C then Enter", text);
I don't want sites to be able to randomly clear my clipboard.There is no API for reading from the clipboard, just writing to it.
The benefits of having a flashless copy/cut function greatly outweigh the off chance some random site will copy something stupid to your clipboard if you interact with 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.
Couldn't you bypass this by creating an invisible button, and then simulating a click event?
I'm sure it's tricky to ensure this, though. Like pop-up blocking.
I guess Mozilla have weighed up the convenience/security balance of browser control of the clipboard, and have put in a minimal protection scheme to make it clear that code should not play with it behind the user's back, but Mozilla knows that they can't really stop it.
How? This security mechanism has been used for (among other things) popups for years now, and the only way it's been worked around is by attaching click handlers to links the user is likely to click.
User-initiated != user-approved, at least not unless the user is specifically asked. (Like by, say, prompting allow/allowalways / deny / denyalways)
Trust me, selecting text is not a problem. I haven't seen a place where click to select was a life savior.