Here note line:
document.querySelector('dialog')
this is something new what I learned today.
Live example:
Example taken from this web site, via this one. On Tympanus you can find few more examples of overlay window, if you need support for older browsers.