Document.execCommand() has been deprecated and altthough some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes, my alternative uses instead the Clipboard API to copy the generated password to the clipboard