***(shuld be HTTPS )*** function myFunction() { var copyText = document.getElementById("copy"); copyText.innerHTML=html; document.execCommand("copy"); alert("Copied the text: " + copyText.value); }