Developer Checklist — JavaScript Appendices

Correct code

JS_N_A6: Do not automatically refresh the page without user confirmation or control

This example shows how user-preferences can be used to provide control over automatic page refreshes. Automatic refreshes are often used on pages with information which updates frequently in real-time, such as stock prices or live sports results.

But automatic refreshes are particularly intrusive for people using a screenreader, because these devices read linearly (from top-to-bottom), so their users can't quickly scan the text to find their place, as is possible with sighted reading. For a screenreader user, an automatic refresh means they lose their place in the text and are forced back to the start.

The general rule here is do not automatically refresh the page (at all). But a caveat can made to say that it's okay to do so if the user has the ability to prevent it, either by explicit confirmation (i.e. using a confirm() dialog), or with user-preferences that default to not refreshing.

Live Demo

The form below allows you to specify the speed of automatic page refreshes. After you press the Save button, the page will refresh once, and then again as often as specified by your settings, which default to Never:

Refresh the page ...

JavaScript Code

The JavaScript code for this example can be found in: JS_N_A6.js