Alert Boxes, Error Messages, and Pop-up Windows
Don't hide warnings, disclaimers or error messages with JavaScript or other client-side scripting. If a message is important, it is always important. Hidden content in dynamic pages will not be available to Web devices that don't support the particular script language. If you cannot imagine showing a warning or disclaimer before it is necessary, then try to develop a server-side solution that will rebuild and serve a modified page with the warning embedded in it.
Sites should also avoid launching secondary browser windows (ie: Pop up windows, etc.) which would be a contravention of the W3C WCAG - Priority 2 10.1 guideline:
Until user agents allow users to turn off spawned windows, do not cause pop-ups or other windows to appear and do not change the current window without informing the user.
Spawning secondary windows is not universally supported in all user agents and has a number of accessibility issues attached to them; here are just a few scenarios:
- Someone with low vision
...will often enlarge the screen so that they are only looking at a small portion of the available screen space. When a popup window occurs, it may appear in an area that the screen enlarger is not enlarging, thus confusing the person because the popup is not visible. However, the default behaviour of most screen enlargers is to move the visual focus to the area of the screen that receives the programming focus, so it is possible that the screen enlarger will jump to the location of the popup window: most will do this, but not all.
- Someone with a cognitive disability
...may or may not know why an error message popped up and may or may not know how to deal with it. Launching a whole new instance of a browser (using target="_blank" for example) will also disrupt the user's session history: the common complaint is that their "Back button" does not work, as the previous browsing history is not present in the new browser window.
- Generally, someone using a screen reader
...will likely hear the contents of the popup window being read out loud, however it can cause spatial disorientation in blind users and should be avoided.
Many pop-up windows also invoke JavaScript to launch the window. Not all devices will support JavaScript, at which point the content has become inaccessible. If you must use Pop-ups, then at the very least use the following (or similar):
<a href="file.html" onClick="window.open('file.html'); return false;">
... at which point, should the JavaScript function fail (due to lack of support or being disabled) then the standard link to the "file.html" will be invoked - taking the user to that information.
Update:
Roger Johansson, of 456 Berea St. has created an accessible JavaScript solution which degrades nicely on machines without JavaScript support. However, even Roger states:
Opening new windows should almost always be avoided. There are very few exceptions to that rule. However, sometimes it is beyond your control as a Web developer to enforce that.
Roger's solution can be found at:
http://www.456bereastreet.com/archive/200610/
opening_new_windows_with_javascript_version_12/
