I have an app that takes a URL as an input, replaces the domain, and returns a new URL in the same input box.
I added a copyText function to copy the new URL to the clipboard. The code works locally, on JSFiddle, and on my S3 account. When I embed the app onto other pages as an iframe, all my functions work except the copyText function. I'm also noticing that function doesn't work here either. What am I doing wrong?
function copyText() {
var copyText = document.getElementById("input");
copyText.select();
copyText.setSelectionRange(0, 99999);
navigator.clipboard.writeText(copyText.value);
alert("Link copied.");
}
<input id="input" type="text" placeholder="Enter text..." autocomplete="off"/>
<button id="copy" onclick="copyText()">Copy</button>
https://jsfiddle.net/ianjmonk/07dwg6sr/21/#&togetherjs=VPAalw11ob