If I add a prompt to the function it works once, but gives the error:
"Uncaught (in promise) DOMException: Document is not focused" at the second attempt.
This is the code:
function site(str) {
var url = prompt();
var text = 'The URL is ';
(async() => {
await navigator.clipboard.writeText(text + url);
})();
}
<button class="button" onclick='site()'>URL</button>
I've asked my best friend, Google, but I can't find any solutions. What am I doing wrong?