This feature is not Baseline because it does not work in some of the most widely-used browsers.
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.
A string; possible values are:
anyThe dialog can be dismissed with a light dismiss user action, a platform-specific user action, or a developer-specified mechanism.
closerequestThe dialog can be dismissed with a platform-specific user action or a developer-specified mechanism.
noneThe dialog can only be dismissed with a developer-specified mechanism.
closedBy usage<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>
const dialogElem = document.querySelector("dialog");
// Logs "any" to the console
console.log(dialogElem.closedBy);
| Specification |
|---|
| HTML> # dom-dialog-closedby> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
closedBy |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | No | 134 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/closedBy