DOM Window.confirm() Method
The confirm() method shows a dialog with OK and Cancel buttons and returns true or false depending on the user's choice.
Description
The confirm() method shows a modal dialog with a message and OK and Cancel buttons, and returns true or false. Like alert(), it blocks the page until answered and can't be styled. A <dialog> lets you write clearer button labels, such as "Delete" and "Keep".
While the dialog is open, all scripts on the page are paused, and the browser may let the user block further dialogs from the page, in which case confirm() returns false immediately. Dialogs are also blocked in sandboxed iframes without the allow-modals permission.
For destructive actions, a custom confirmation in a <dialog> can explain the consequences and use specific button labels, which users read more carefully than a generic OK and Cancel. An undo option after the action is often friendlier still.
Syntax
confirm(message)Parameters
- messageThe question to show.
Return Value
true if the user clicked OK, false if they clicked Cancel.
Example
Browser Support
The following information will show you the current browser support for the Window.confirm() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





