i have a question, i have a code, which is partially working.
let dataName = "String"
navigator.clipboard
.writeText(dataName) //push string into clipboard
.then(() => {
alert(dataName + "successfully copied");
closeWindow()
})
.catch(() => {
alert("something went wrong");
});
In this version, the code is pushing dataName into the clipboard and gives an alert, after that it closes it. If i delete the alert, it closes the window, without copying it into the clipboard, not going into the catch ("something went wrong"). I do not want to have the alert, it should just push the string into the clipboard and closes it. Note: Code is embedded into a HTML, which is empty, except of the script. Code is partially from: How do I copy to the clipboard in JavaScript?