HTMLDialogElement: closedBy property

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The closedBy property of the HTMLDialogElement interface indicates the types of user actions that can be used to close the associated <dialog> element. It sets or returns the dialog's closedby attribute value.

Value

A string; possible values are:

any

The dialog can be dismissed with a light dismiss user action, a platform-specific user action, or a developer-specified mechanism.

closerequest

The dialog can be dismissed with a platform-specific user action or a developer-specified mechanism.

none

The dialog can only be dismissed with a developer-specified mechanism.

Examples

Basic closedBy usage

html
<dialog open closedby="any">
  <h2>My dialog</h2>
  <p>
    Closable using the Esc key, or by clicking outside the dialog. "Light
    dismiss" behavior.
  </p>
</dialog>
js
const dialogElem = document.querySelector("dialog");

// Logs "any" to the console
console.log(dialogElem.closedBy);

Specifications

Specification
HTML
# dom-dialog-closedby

Browser compatibility

See also