Pan of gold nuggets Popups: Native Browser Alerts and Prompts versus Modals Pan of gold nuggets

The use of native browser alerts and prompts is very common. They are easy to implement using a few simple lines of JavaScript, and well supported among browsers. However, they are not well supported among screen readers.


Problem: The text of the Alert is not read properly by JAWS when using Google Chrome (GC).

Solution: Use a Modal instead.

Gold nuggetNative Browser Alert Example

Steps to test for accessibility:

  1. With this page open, start JAWS screen reader.
  2. Navigate to the Save Changes button below, select it.
  3. Using Google Chrome, JAWS reads: "Accessibilityuniversity dot dhs dot int dot state dot mn dot us dialog says OK button".
  4. Using Firefox, JAWS reads: "Popups: Native Browser Alerts and Prompts versus Modals dash Mozilla Firefox horizontal tab panel dialog your changes have been saved OK press spacebar to activate".

Gold nuggetModal Example

Steps to test for accessibility:

  1. With this page open, start JAWS screen reader.
  2. Navigate to the Save Changes button below; select it.
  3. Using Google Chrome, JAWS reads: "Save Changes Modal Example your changes have been saved OK".
  4. Using Firefox, JAWS reads: "Save Changes Modal Example your changes have been saved OK".


Gold nuggetDiscussion: Modals vs Native Browser Alerts

Native browser alerts and prompts are not recommended due to the lack of control over what is rendered. They are rendered by the browser and accept only the text of the message and button as inputs.

Modals are coded in HTML and allow full control over all parts of the popup, including the ability to embed aria labels.

Coding Modals for accessibility

The use of aria labels should be included in the <div> class tags declaring the Modal: aria-labelledby and aria-describedby.

Code

Code for modal

For more information: