Forum Discussion
BenKanspedos-8b
3 years agoCommunity Member
Why does this box appear when I do Javascript to copy text to clipboard?
I have some buttons to let user copy text to clipboard. But a weird thing happens. the text shows up on the upper right and it doesn't go away.
It's a bit annoying.
How can I get rid of it?
...
BenKanspedos-8b
3 years agoCommunity Member
Thank you Math. Removing that line did remove the box, but it also prevented it from copying to my clipboard. However, it helped me understand the problem better.
I was able to get updated code from chatGPT which removes the box
var player = GetPlayer();
var text = player.GetVar("ChatOpening");
copyFunction (text);
function copyFunction(tt) {
const copyText = tt;
const textArea = document.createElement('textarea');
textArea.textContent = copyText;
document.body.append(textArea);
textArea.select();
document.execCommand("copy");
document.body.removeChild(textArea);
}