Nowdays, you can use an HTML dialog
element.
And do what you want with it.
document.querySelectorAll('button').forEach($button =>
$button.onclick = () => document.querySelector('dialog').removeAttribute('open'))
https://jsfiddle.net/6nus2zt4/1/
Hope this help to future generations :)