title: Javascript code for "Copy to Clipboard" won't work in Internet Explorer 11
body: <p>I have a piece of Javascript code that currently makes a call to a specific webpage, returns the data, then copies it to the clipboard.  It's working in Chrome, Safari, and Firefox, but for some reason the copy functionality won't work in IE 11.</p>
  
  <p>The response body is being returned with the correct data, but I can't seem to get that data to the clipboard.  The code needs to be pure Javascript, as it's being utilized through a developer portal with some limitations/restrictions. In essence, <strong>I want to avoid importing jQuery libraries/using jQuery</strong>.</p>
  
  <pre><code>function httpGet(theUrl)
  {
     if (window.XMLHttpRequest)
     {// code for IE7+, Firefox, Chrome, Opera, Safari
         xmlhttp=new XMLHttpRequest();
     }
     else
     {// code for IE6, IE5
         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
     xmlhttp.onreadystatechange=function()
     {
         if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
         {
             function listener(e) {
               e.clipboardData.setData("text/html", xmlhttp.responseText);
               e.clipboardData.setData("text/plain", xmlhttp.responseText);
               e.preventDefault();
             }
             document.addEventListener("copy", listener);
             document.execCommand("copy");
             document.removeEventListener("copy", listener);
  
             return xmlhttp.responseText;
         }
     }
     xmlhttp.open("GET", theUrl, false );
     xmlhttp.send();
  }
  </code></pre>
  
  <p>The function is being called in an "onclick" HTML event, which is firing normally from what I understand (considering the call to "theUrl" page is being made and returning data).  Any input on why the clipboard isn't getting the data would be GREATLY appreciated. Thanks!</p>