I didn't need any JS here:
<dialog open> <p>Greetings, one and all!</p> <form method="dialog"> <button>OK</button> </form> </dialog>
And if you don’t want it open when you load the page?
And if you don’t want it open when you load the page?