Exit a Page Quickly

Let users quickly and safely leave your service when they need to hide their activity, such as when escaping domestic abuse.

Safety critical

This pattern is used in services where users may be in danger. It must be thoroughly tested and work reliably in all situations.

When to Use

  • Services about domestic abuse or violence
  • Services dealing with sensitive personal information
  • Any service where users might need to quickly hide their activity
  • Services where someone might be monitoring the user's device

Key Requirements

An effective exit solution must:

  • Be immediately visible and accessible
  • Work with a single click or keyboard shortcut
  • Redirect to an unsuspicious website (like Google)
  • Not appear in browser history
  • Work without JavaScript (as a fallback)
  • Clear any entered data from the page

Exit Button

Place a prominent exit button in a fixed position, usually top-right of the page.

<div class="exit-this-page">
  <a href="https://www.google.com" class="exit-this-page-button" rel="noopener noreferrer">
    <span class="exit-this-page-icon" aria-hidden="true">&times;</span>
    <span class="exit-this-page-text">Exit this page</span>
  </a>
</div>

Keyboard Shortcut

Provide a keyboard shortcut for users who cannot easily reach the button. The standard shortcut is pressing the Escape key 3 times quickly.

Exit this page

Or press Esc key 3 times

Visual Feedback

Show visual feedback when users start the escape sequence, so they know it's working.

JavaScript Implementation

// Exit This Page component
(function() {
  const exitUrl = 'https://www.google.com';
  let escapeCount = 0;
  let escapeTimer;

  // Keyboard shortcut: Triple Escape
  document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape') {
      escapeCount++;

      clearTimeout(escapeTimer);
      escapeTimer = setTimeout(function() {
        escapeCount = 0;
      }, 1000);

      if (escapeCount >= 3) {
        exitPage();
      }
    }
  });

  // Button click
  document.querySelectorAll('.exit-this-page-button').forEach(function(button) {
    button.addEventListener('click', function(e) {
      e.preventDefault();
      exitPage();
    });
  });

  function exitPage() {
    // Clear any form data
    document.querySelectorAll('input, textarea, select').forEach(function(el) {
      el.value = '';
    });

    // Replace history to hide visit
    window.location.replace(exitUrl);
  }
})();

Browser History

Important considerations for browser history:

  • Use window.location.replace() instead of window.location.href
  • This replaces the current history entry rather than adding a new one
  • The service pages won't appear in the "Back" button history
  • Users should still be advised to clear their full browser history

Safety Information

Consider providing safety information alongside the exit button:

Cover your tracks

The "Exit this page" button will take you to Google and remove this page from your recent browser history.

However, if you're worried someone might see you visited this site, you should also:

  • Clear your full browser history
  • Use private/incognito browsing
  • Access this service from a device you control

Positioning

.exit-this-page {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 100;
}

@media (max-width: 640px) {
  .exit-this-page {
    top: var(--space-2);
    right: var(--space-2);
  }
}

Testing Requirements

Test the exit functionality:

  • Works with mouse, keyboard, and touch
  • Works on all supported browsers
  • Falls back to standard link when JavaScript is disabled
  • Works on slow connections
  • Is visible on all page layouts
  • History replacement works correctly

Related Components