Antony Clinton

Antony Clinton

  • NA
  • 34
  • 3.4k

Copy to Clipboard Functionality

Sep 20 2017 11:09 AM
I tried a Copy to Clipboard fuctionality using a Javascript. It is working in IE but not in Google Chrome. Below were my code
<script type="text/javascript" language="javascript">
function copy(strc) {
var controlValue =strc;
if (window.clipboardData) { // Internet Explorer
console.log("show");
window.clipboardData.setData("Text", controlValue);
}
else{
var aux =strc;
//aux.setAttribute("value", document.getElementById(elementId).innerHTML);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
}
//window.clipboardData.setData('Text', controlValue);
}
</script>
 
Kindly, help me how to achieve this in Chrome 
 

Answers (1)