alert, confirm and prompt dialogs
Blocks the page with a modal alert, confirm or prompt box.
In one line
Can freeze the page with a pop up message box until you answer it
Blocks the page with a modal alert, confirm or prompt box.
A site can interrupt the person with a message or a text box. Dialogs freeze the page script, are easy to abuse, and are blocked in cross-origin iframes and background tabs.
What it can and can't do
What the user does: Nothing. It happens when the page runs a script, or after an action like Delete.
It can
- Show an alert, a yes or no question or a box asking you to type text
- Pause the page until you tap OK or Cancel
- Ask Are you sure you want to leave? before you close the tab
It cannot
- Show the box on tabs you are not looking at in most browsers
- Pause other tabs or other apps
- Fill your screen with endless boxes; browsers let you block more from that page
- See what you type into other sites
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 1 | 2008-12-11 | None |
| Edge | Supported | 12 | 2015-07-29 | None |
| Firefox | Supported | 1 | 2004-11-09 | None |
| Safari | Supported | 1 | 2003-06-23 | None |
| Safari on iPhone | Supported | 1 | 2007-06-29 | All iOS browsers use WebKit |
| Chrome on Android | Supported | 18 | 2012-06-27 | None |
| Samsung Internet | Supported | 1.0 | 2013-04-27 | None |
How a site asks for it
| API | window.alert(), window.confirm(), window.prompt() |
| Browser compat keys | api.Window.alertapi.Window.confirmapi.Window.prompt |
| How access is granted | none |
| What the user sees | None (no browser prompt) |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| Activation | none |
| How long it lasts | One-shot; Chrome adds Prevent this page from creating more dialogs after repeats |
| How to take it back | Nothing to revoke (no permission is stored) |
| Inside an iframe | Blocked in cross-origin iframes in Chrome 92 and later; sandboxed frames need allow-modals |
Typical flow
- Script calls alert/confirm/prompt
- Browser shows modal dialog and blocks the page thread
- Return value goes back to script
Data you get
Shape: none
No individual data fields. The signal is the access itself.
Technical limits
- Cross-origin iframe dialogs are blocked in Chrome 92 (and Safari, Firefox have similar restrictions); same-origin iframes still allowed
- Dialogs from background tabs are queued until the tab is foregrounded in Chrome
- Chrome shows a Prevent this page from creating more dialogs checkbox on repeated dialogs
- Dialog text is plain text, no HTML; Chrome shows the origin in the title
- Modal blocks the whole event loop of the tab (and other same-process tabs may freeze)
The story
What it is
A site can pop up a message box that freezes the page until you click.
For you
You see a grey box that says something like 'Leave site?' or 'Are you sure?' and the page stops until you answer. Scam sites use fake versions to scare you.
For makers
Makers use these for the simplest possible yes or no and for quick debugging. Browsers now limit them, so serious apps build their own dialogs instead.
Where you see it
| Type | Example | Apps |
|---|---|---|
| productivity | An online editor asks 'Discard unsaved changes?' when you try to close the tab. | Google Docs, WordPress editor |
| shopping | A checkout page asks 'Are you sure you want to leave? Your cart will be lost.' | None named |
| security | A fake 'Your computer is infected, call this number' alert loops on a scam site until you force quit. | None named |
| developer | A developer drops quick alert boxes into code to see a value while testing. | None named |
| games | A simple browser game confirms 'Restart level?' before wiping your progress. | None named |
| enterprise | An old internal admin tool asks 'Delete 40 records?' with a plain browser confirm box. | None named |
Risks
- Scareware pop ups
- Trapping the tab
Good uses and abuse
Legitimate uses
- Simple debugging
- Legacy confirm before delete
Known abuse
- Scam warnings (fake virus alerts)
- Dialog loops that trap the tab
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 1 of 5 | How revealing the data is |
| Utility | 2 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | Not rated | Rough identifying entropy, when known |
History
- 2021-07, Chrome 92: Cross-origin iframe alert, confirm, prompt blocked
- 2023-09, Firefox 117: Dialog from background tab queued; tab-modal dialogs introduced earlier
Related capabilities
Related
- Leave-page confirmation (beforeunload). Can show a generic Leave site? warning when you close or leave, after you have interacted
Sources
How well checked: Based on official documentation.