title: Copy to Clipboard using document.execCommand('copy',false,null) is working only in MS browsers
body: <p>I have a grid that lists a huge amount of data. For each data row, I have a button that copies the specific row to the system clipboard.</p>
  
  <p>The row button/link calls the javascript method in which I call the MVC controller method and pass the data to the textarea (styles applied to make it not visible).</p>
  
  <p>Till a few days back it was working with all browsers (mainly needed to work in IE, Edge, Chrome, and Safari). Now the code is not working.</p>
  
  <p>My javascript method goes this way:</p>
  
  <pre><code>function copytoclip(id) {
    $.get('/controller/details', {
          'commentid': id
        }, function(data) {
          var txt = document.getElementById('&lt;%=txtcontrol.ClientID%&gt;');
          txt.value = data;
          txt.textContent = data;
  
          txt.select();
  
          try {
  
            //Below line returns false always in Chrome and Safari
            var res = document.execCommand('copy', false, null);
            if (res) {
              alert('Copy to clipboard successful');
            } else {
              alert('Your browser doesn'
                t support clipboard access ');}
              }
              catch (err) {
                alert(err.message);
              }
            });
        }
  </code></pre>
  
  <p>The result (res) is always false in Chrome and Safari. I tried to add the URL (<a href="http://servername:portname" rel="nofollow noreferrer">http://servername:portname</a> - runs in localhost; even it fails with the DNS in staging) to the Chrome's trusted site list for the clipboard access but in vein.</p>
  
  <p>Can anyone give direction why the execCommand returns false always in Chrome and Safari?</p>