I just saw on the Mozilla page that execCommand() is obsolete https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
This is what I currently use to copy text to the user's clipboard when the user clicks a copy text button. Is there another way to do it?
var input = // input element with the text
input.focus();
input.setSelectionRange(0,99999);
document.execCommand(copy);
input.blur();
Edit: This How do I copy to the clipboard in JavaScript? does not answer the question. It suggests the same obsolete solution.