0

I am using the below button to read data from a web service and display it in a prompt window. The problem I am having is newer versions of Chrome and FireFox and now IE 11 do not allow data to be copied to clipboard.

I have used Postman to test the end point /Areas/Journal/Handlers/CSVString.ashx it is returning data. but the below code is showing an empty box

Is there a way to copy data to clipboard without using flash ? Any ideas why I am getting an empty window in IE when I run the below code ?

<input id="htmlCopyCSV" type="button" value="Copy" onclick="$.get('/Areas/Journal/Handlers/CSVString.ashx', function (data) { alert(data);window.prompt('Copy to clipboard: Ctrl+C, Enter', data); });" />
DeveloperLife
  • 21
  • 2
  • 5

1 Answers1

0

Bind this function to the copy button

function myFunction() {
  var copyText = document.getElementById("myInput");
  copyText.select();
  document.execCommand("Copy");
  alert("Copied the text: " + copyText.value);
}
Lockless
  • 497
  • 1
  • 5
  • 12