I have this function and i call it with onClick. On Google Chrome (windows) is working but on the Android Chrome is not. How can i make it to work ontouch, in Android Chrome?
Thank you!
function copyCupon(cupon, link) {
var copyText = document.createElement("input");
document.body.appendChild(copyText);
copyText.setAttribute("id", "copyTextId");
copyText.setAttribute('value', cupon);
copyText.select();
document.execCommand("copy");
document.body.removeChild(copyText);
alert("Cuponul " + "'" + copyText.value + "'" + " a fost copiat. Spor la cumparaturi! :)");
window.open(link);
}
<button onclick="copyCupon('test to copy', 'http://www.google.ro')">Copy coupon</button>