← Back to release summary

Constructor for DataTransfer

Category
User input
Type
New or changed feature
Status
Enabled by default (Chrome 60)
Intent stage
None

Summary

The new asynchronous clipboard API makes use of DataTransfer objects and has a need to be able to construct new ones. For example (with new clipboard api): var data = new DataTransfer(); data.items.add("\(°o°)/", "text/plain"); navigator.clipboard.write(data).then(function() { console.log(“Copied to clipboard successfully! ᕕ( ᐛ )ᕗ”); }, function() { console.error(“Unable to write to clipboard. (╯ಠ_ಠ)╯︵ ┻━┻”); });

Standards & signals

Ecosystem

Docs: https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/DataTransfer

Samples: https://w3c.github.io/clipboard-apis/#h-clipboard-write-data

View on chromestatus.com