3 ms·
> So can a website read a users clipboard Yes and no, the website can access clipboard data specifically when you're pasting as a user-triggered operation (C-v
by masklinn 13y ago
> So can a website read a users clipboard
Yes and no, the website can access clipboard data specifically when you're pasting as a user-triggered operation (C-v/M-v or "Paste" from a contextual menu) (that is the clipboard data is only accessible from the `paste` event).
This allows an application to access alternative representations (the clipboard can store multiple representations of the same data e.g. text and html and image and whatever, and the application can then pick the most appropriate — or all of them) and to pre-process clipboard data before inserting it programmatically. Very useful with e.g. RTE. Arbitrary clipboard access most definitely isn't allowed.
See http://www.w3.org/TR/clipboard-apis/#pasting-html-and-multi-part-data http://www.w3.org/TR/clipboard-apis/#pasting-html-and-multi-... for security and privacy considerations.
> if yes, how can we disable this "feature"?
In firefox, probably by going to about:config and setting `dom.event.clipboardevents.enabled` to `false`. In webkit and MSIE (which have had the feature for ages) I have no idea.
- aaronm67 13y agoIn Firefox, it seems like you can only catch Clipboarddata on input boxes still document.body.addEventListener("paste", function(e){ console.log("paste event fired") }) In Chrome, this will fire when you paste, in Firefox it will not.
- masklinn 13y agoIt might be restricted to focusable/editable components, e.g. a `contenteditable` block should work.
- aaronm67 13y agoYep, you're correct http://jsbin.com/odupog/1/edit http://jsbin.com/odupog/1/edit Either way, should alleviate some of the privacy concerns, as you can only get ClipboardData from elements where "paste" has a visible effect.