He incrustado un sitio web dentro de otro sitio web usando iframe.. <iframe src=..">.. Dentro del sitio web incrustado hay un botón de copia. Cuando lo uso en el sitio web (sin incrustar) funciona. Pero cuando lo uso en iframe no..
Mi código de botón: <button onclick="copy()">copy</button> Js:
function copy() { let copyText = document.getElementById("resu"); copyText.select(); copyText.setSelectionRange(0, 99999); /* For mobile devices */ navigator.clipboard.writeText(copyText.value.replace(/A /, "A ")).then(function() { alert("Copied to clipboard."); }, function(err) { alert("Could not copy text."); }); }¿¿Qué ocurre??