Get to know MDN better
Since May 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The requestClose() method of the HTMLDialogElement interface requests to close the <dialog>. An optional string may be passed as an argument, updating the returnValue of the dialog.
This method differs from close() in that it fires a cancel event before firing the close event. Authors can call Event.preventDefault() in the handler for the cancel event to prevent the dialog from closing.
This method exposes the same behavior as the dialog's internal close watcher.
A string representing an updated value for the HTMLDialogElement.returnValue of the dialog.
None (undefined).
The following example shows a button that, when clicked, opens a <dialog> using the showModal() method. From there you can click the either Close button to call the requestClose() method and close the dialog.
The Close button closes the dialog without a returnValue, while the Close w/ return value button closes the dialog with a returnValue.
Preventing the dialog from closing is demonstrated with a checkbox.
| HTML # dom-dialog-requestclose |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jan 26, 2026 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.