Dialogs, modal and not

Use the keyboard as well as the mouse: Tab, Shift+Tab, Enter and Escape.

Focus is on: nothing yet

What this browser supports

dialog, show(), showModal()
checking…
closedby attribute
checking…
requestClose()
checking…
commandfor / command
checking…

1. Non-modal and modal

The non-modal dialog opens in the corner and the page stays usable: try clicking these buttons again while it is open. Escape does nothing to it. The modal dialog makes the rest of the page inert, dims it with ::backdrop, and closes on Escape.

A dialog, opened ?

Focus moved to the first focusable element inside. Close the dialog and watch the readout: focus returns to the button that opened it.

2. A form with method="dialog"

Each button submits the dialog's form. Nothing is sent over the network: the dialog closes, and the submitting button's value becomes the dialog's returnValue. Escape closes it too, and leaves the value unchanged.

Last returnValue: (not opened yet)

Delete this draft?

The draft cannot be recovered.

  • 3. Opened by an invoker, no script

    These buttons carry commandfor and command. Where invoker commands are supported, the browser opens and closes the dialogs itself; elsewhere, the fallback script at the end of this page wires the same buttons by hand. The second dialog has closedby="any": a click on the backdrop closes it, where supported.

    Opened by: (not opened yet)

    Opened declaratively

    The button that opened this dialog named it with commandfor. This one closes it with command="close".

    Light dismiss

    Click the dimmed page outside this box, or press Escape. Without closedby support only Escape works, so a visible close button stays.