HTML 5.2 has introduced a new <dialog> element to show modal dialog boxes. Here’s a small demo by @bdc (forked version by me, including polyfill):

Already available in Chrome; a polyfill is available for other/older browsers.

Meet the New Dialog Element →

Polyfill for the HTML <dialog> element →