window.confirm() Confirm dialog
Last updated: 2026-09-09
window.confirm() Confirm dialog
confirm shows a dialog with OK/Cancel and returns a boolean.
| Category | Browser (BOM) |
|---|---|
| ES version | DOM |
📝 Syntax
const result = confirm(message);
⚙️ Parameters
| message | The confirmation message. |
|---|
Returns:true for OK, false for Cancel.
Mutates the original:No (returns a new value)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
deleted
💡 Tip confirm returns a boolean — use directly in if.
⚠️ Warning confirm blocks the page — use custom dialogs in production.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| window.confirm() | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported by all modern browsers | |||||
🏷️ Related Items
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
QWhat does confirm return?
Atrue for OK, false for Cancel.
QCan confirm customize buttons?
ANo — use custom HTML dialogs.
QWhen to use confirm?
ADelete confirmations and irreversible actions.