Edge clipboard setData example

by Seungrae Lee

HTML

<span>Copy this text and try to paste it in the input.</span>
<br />
<input id="area"></input>
<button type="button" name="btn" value="Copy" onclick="SaveToClipboard();">Copy</button>

JavaScript

function SaveToClipboard() {
  document.execCommand('copy');
}
document.observe('copy', function(e) {
  var inputVal = $('area').value;
  e.clipboardData.setData("text/plain", inputVal);
  e.preventDefault();
});