Skip to Content
Platform.Ontology

alert, confirm and prompt dialogs

Blocks the page with a modal alert, confirm or prompt box.

Does something on your deviceThings a page can doWindows and navigationWeb browsersWhile you use it

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

BrowserStatusFirst versionReleasedNote
ChromeSupported12008-12-11None
EdgeSupported122015-07-29None
FirefoxSupported12004-11-09None
SafariSupported12003-06-23None
Safari on iPhoneSupported12007-06-29All iOS browsers use WebKit
Chrome on AndroidSupported182012-06-27None
Samsung InternetSupported1.02013-04-27None

How a site asks for it

APIwindow.alert(), window.confirm(), window.prompt()
Browser compat keysapi.Window.alert
api.Window.confirm
api.Window.prompt
How access is grantednone
What the user seesNone (no browser prompt)
Needs a secure context (HTTPS)No
Needs a user gestureNo
Activationnone
How long it lastsOne-shot; Chrome adds Prevent this page from creating more dialogs after repeats
How to take it backNothing to revoke (no permission is stored)
Inside an iframeBlocked in cross-origin iframes in Chrome 92 and later; sandboxed frames need allow-modals

Typical flow

  1. Script calls alert/confirm/prompt
  2. Browser shows modal dialog and blocks the page thread
  3. 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

TypeExampleApps
productivityAn online editor asks 'Discard unsaved changes?' when you try to close the tab.Google Docs, WordPress editor
shoppingA checkout page asks 'Are you sure you want to leave? Your cart will be lost.'None named
securityA fake 'Your computer is infected, call this number' alert loops on a scam site until you force quit.None named
developerA developer drops quick alert boxes into code to see a value while testing.None named
gamesA simple browser game confirms 'Restart level?' before wiping your progress.None named
enterpriseAn 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

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility2 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bitsNot ratedRough 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

Sources

How well checked: Based on official documentation.

On this page