Does Safari’s clipboardData actually work?
I’ve been playing around with the
clipboardData object in Internet Explorer and Safari all weekend. IE’s access is pretty straightforward, the object is located on
window and always available. Safari adds
clipboardData to the
event object, but only during clipboard events. You can only read clipboard data in Safari in an
onpaste event handler, but it’s unclear when, if ever, you can set data to the clipboard. I’ve tried several things and haven’t successfully been able to get data onto the clipboard.
clipboardData is only available during clipboard events, that means you can only use it in response to the user initiating one of these events and not in response to any other user action. I’ve tried overriding the
copy events, trying to set the clipboard data myself and using
preventDefault() to cancel the default behavior, but this doesn’t work.
I took a quick look at the source code and it looks like perhaps this feature just isn’t enabled. It seems that the
types property hasn’t been implemented either, even though the documentation says it should be there. The
setData() method just returns
false every time, I’ve tried using “text”, “Text”, and “text/plain” as the first argument but it doesn’t seem to matter. Has anyone been able to set data onto the clipboard in Safari?
Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.
Both comments and pings are currently closed.