Skip to content

Technique G201:Giving users advanced warning when opening a new window

About this Technique

This technique relates to:

This technique applies to pages that open new windows.

Description

The objective of this technique is to provide a warning before automatically opening a new window or tab. Opening new windows automatically when a link is activated can be disorienting for people who have difficulty perceiving visual content, and for some people with cognitive disabilities, if they are not warned in advance. Providing a warning allows the user to decide it they want to leave the current window, and the warning will help them find their way back, if they do decide they would like to go to the new window. It will help them understand that the "back" button will not work and that they have to return to the last window they had open, in order to find their previous location.

Examples

Example 1: Including the warning in the text describing a control

The name or label that describes a control can include the warning about opening in a new window.

<a href="knitting.html" rel="noopener" target="_blank">
  All about Knitting (opens in new window)
</a>

Example 2: Using CSS to provide a warning before opening a new window

The code below uses CSS to provide a warning before opening a new window.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Link opens in new window notification</title>
  <style>
    body {
      background:#fff;
      color: #000;
      font: 1rem/1.5 system-ui, "Segoe UI", Roboto, Helvetica, sans-serif;
    }

    [hidden] {
      display:none;
    }

    .new-window-icon {
      fill:currentColor;
      height:0.75rem;
      margin-inline-start:0.3em;
      vertical-align:middle;
      width:0.75rem;
    }
  </style>
</head>
<body>
  <svg hidden>
    <symbol id="new-window-icon" viewBox="0 0 12 12">
      <title id="new-win-desc">opens in a new window</title>			
      ...
    </symbol>
  </svg>

  <h1>Link opens in new window notification</h1>
  <p>This is an example of an 
     <a aria-describedby="new-win-desc" href="https://example.com" rel="noopener" 
     target="_blank">external link<svg class="new-window-icon" aria-hidden="true"
     role="img"><use href="#new-window-icon"></use></svg></a></p>
  </body>
</html>

A working example of Using CSS to provide a warning before opening a new window is available.

Tests

Procedure

For each link that opens automatically in a new window or tab when a change of context is initiated by a user request:

  1. Check that there is a warning spoken in assistive technology that this link opens to a new window.
  2. Check that there is a visual warning in text that this link opens to a new window.

Expected Results

  • Checks #1 and check #2 are true.
Back to Top