I have embedded an website inside another website using iframe..
<iframe src=..">..
Inside the embedded website there is a copy button. When I use it in website(without embed) it works. But when I use it in iframe it doesn't..
My button code:
<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.");
});
}
What's wrong??