Developer Checklist — JavaScript Appendices

Incorrect code

JS_N_A2: Use an actuation event, rather than focus or load event, to programmatically open links or trigger popup windows

This example shows how not to trigger a popup window, from the focus event of an input field. Opening unexpected popups is particularly intrusive for screenreader users, who may not even realise at first that they're reading a different page.

Although many browsers will block such a popup, many will not, since it would be considered a user-triggered event. The existence of popup-blockers cannot be considered sufficient to fix this issue.

The correct way to open popups is described in: JS_N_A3.

Live Demo

Tab or click into the field below, and a popup will attempt to open automatically:

JavaScript Code

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