sudodoki / copy-to-clipboard

Copy stuff into clipboard from your browser using JS
http://sudodoki.github.io/copy-to-clipboard/example/
MIT License
1.33k stars 130 forks source link

Should check options.format for other browser #99

Open qrqhuang opened 4 years ago

qrqhuang commented 4 years ago

for this code fragment, Is it necessary for other browser to check options.format ?

I config wrong with format: 'plain' , and then nothing could paste.

if (typeof e.clipboardData === "undefined") { // IE 11
  debug && console.warn("unable to use e.clipboardData");
  debug && console.warn("trying IE specific stuff");
  window.clipboardData.clearData();
  var format = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"]
  window.clipboardData.setData(format, text);
} else { // all other browsers
  e.clipboardData.clearData();
  e.clipboardData.setData(options.format, text);
}
qrqhuang commented 4 years ago

Which more strange thing is when I import js from wzrd.in , code above runs well. Cause stuck of cdn site , I could not compare source with them.