Open a popup from a link without JavaScript: accessible trigger guide

Learn to open a popup from a link without JavaScript: anchor trigger markup, focus entry and return, Escape behavior, and a one-page keyboard test.

James HollowayWeb Development Lead7 min read

To open a popup from a link without JavaScript, put a real anchor element in your content that a visitor activates, then pair it with a configured WidgetJar popup whose dialog handles focus entry, Escape-to-close and focus return. You get this behaviour because the popup is rendered as a native HTML dialog element, and the browser supplies most of the keyboard handling you would otherwise have to script. Your work is markup, configuration and a short verification pass, not custom script logic.

This guide covers the trigger link, how the link pairs with the popup block, the focus contract visitors expect, a ten-minute keyboard test and the breakages that most often slip through. It assumes you can edit page HTML and configure a widget in the WidgetJar panel.

A link-triggered popup is user-initiated: the visitor chose to read more, request a callback or see the offer. That changes the tone of the interaction. Compare it with a timed popup that interrupts someone mid-paragraph; popup timing is worth reading if you have not settled on a trigger yet.

Link triggers have three practical advantages:

  • Discoverable placement. The link sits in the content where the visitor is already reading, so finding it needs no interruption.
  • Descriptive text. Text such as "See the full price list" tells people what happens next, which a generic "click here" never does.
  • No surprise. Nothing appears until someone asks for it, so a reader scrolling a long service page is never stopped.

Use this pattern for secondary actions such as requesting a callback, opening the detailed spec or viewing appointment options, rather than the single most important action on the page, which is usually clearer as a plain link or button.

A trigger that opens a popup must first be a link in the ordinary sense: a focusable element with visible, meaningful text and an href. If the element is a non-focusable span styled to look like a link, keyboard users cannot reach it, and the interaction breaks before any popup opens.

Write the link text as a promise the popup can keep:

  • Good: "Book a 15-minute callback", "See the full menu", "Request the spec sheet".
  • Weak: "Click here", five repeated "Learn more" links on one page, or an icon with no text.

If the design calls for a button shape, style the anchor as a button rather than switching to a non-link element. The accessible popup checklist goes deeper on trigger labelling across a whole site.

In the WidgetJar panel, configure the popup widget and choose the trigger that matches the link. Keep the trigger link and the popup block in the same page section so it is obvious which link belongs to which popup. When several link triggers exist on one page, give each popup its own unique ID and confirm each link targets the right one. A duplicated ID is the most common cause of "the wrong popup opened".

Heading and label agreement inside the popup

The link text and the popup heading should say the same thing. If the link reads "Request a callback" and the popup title reads "Subscribe to our newsletter", the visitor has been misled. Keep the wording aligned, make the first heading descriptive, and include a clearly labelled close control. The W3C's Dialog (Modal) Pattern strongly recommends a visible close element for every dialog.

How the popup should behave once it opens

The behaviour contract is short and well documented. The same W3C Dialog (Modal) Pattern sets out the expectations: when a dialog opens, focus moves to an element inside it; Tab and Shift+Tab keep focus within the dialog; Escape closes it; and when it closes, focus returns to the element that invoked it.

That last point matters most for a link trigger. If focus drops back to the top of the page, a keyboard user has lost their place and must tab through everything again to reach the link they just used.

Why the native dialog element helps

The HTML dialog element carries much of this behaviour built in. The MDN reference for the HTML dialog element explains that a modal dialog opened with showModal() makes the rest of the page inert, that focus is set on the first nested focusable element, and that Escape closes it by default. It also warns that you should not add tabindex to the dialog element itself, because the dialog is not interactive; its contents are.

If you are weighing this against a hand-built overlay, the dialog element vs custom modal div comparison covers what you would have to replicate yourself.

Reserve the page space before you launch

Adding a popup block to a page should not move the content around it. Two things to verify:

  1. The trigger link keeps its position in the layout while the popup is closed.
  2. The popup container does not leave a visible gap or shift surrounding text once the embed script runs.

Measure before and after using the method in reserve space for popup embed to prevent layout shift. A shift of a few pixels mid-sentence is enough to make a reader click the wrong link.

A one-page keyboard test: ten minutes, no code

Run this on the real page after the embed script is installed on the registered domain, with the mouse put away.

  • Tab through the page and confirm the trigger link receives a visible focus outline in reading order.
  • Confirm the link text reads clearly on its own, without the surrounding sentence.
  • Press Enter on the link and confirm the popup opens.
  • Confirm focus lands inside the popup, usually on the close button or first form field, not on the page body.
  • Tab repeatedly and confirm focus never leaves the popup.
  • Press Shift+Tab from the first control and confirm focus wraps to the last control inside the popup.
  • Press Escape and confirm the popup closes.
  • Confirm focus returns to the exact link that opened it, not the page top.
  • Repeat with a second link trigger on the same page if one exists.
  • Reload and confirm no popup appears without a click.

If any step fails, the modal focus management test script expands each check with the likely cause.

Common breakages to check before launch

Most failures fall into a short list:

  • No visible link text. An icon-only trigger with no accessible name is unnameable or unreachable. Add text or a proper label.
  • A non-focusable element. A span or div styled as a link is not a trigger. Use an anchor with an href.
  • Focus lands on the page body. The popup opened but focus was never moved inside, so a screen reader user hears nothing new.
  • Focus does not return. Escape closes the popup but the visitor is dumped at the document start.
  • Popup fires without a click. A trigger is misconfigured or duplicated, so a popup appears on load.
  • Wrong popup opens. Two blocks share an ID, or two links point at the same popup.
  • Link text sits off-screen on mobile. Position the link so it is visible at narrow widths, not hidden behind a fixed element.

Panel versus browser: where to look

Split your troubleshooting on purpose. In the WidgetJar panel, check the trigger configuration, the popup content and heading text, and whether more than one popup is enabled on the page. In the browser, check that the rendered anchor has an href, that the link is focusable, that only one element carries each ID, and that the popup appears only after activation. If two popups clash, the multiple popups on one page conflict guide walks through trigger mapping and priority.

Frequently asked questions

Can a link open a popup with no JavaScript at all? A plain anchor navigates; opening an in-page dialog needs the embed script that WidgetJar installs, added once to the site rather than per popup. The link stays as the trigger your visitors interact with.

Should the trigger be a link or a button? If the action reveals in-page content, a button-styled link is usually the clearer signal. Either way, keep it focusable and give it readable text.

What if the popup contains a form? Keep the same focus contract, give every field a visible label, and test submission with the keyboard.

Ready to wire it up

Configure your link-triggered popup on the WidgetJar popup widget page, install the embed script on your registered domain, then run the keyboard test above before you publish. If you need to compare options for your site, current plan details are on the pricing page.

  • open a popup from a link without JavaScript
  • popups
  • accessibility
  • keyboard testing
  • html

Written by

James Holloway

Web Development Lead at WidgetJar

Keep reading

Popups9 min read

dialog element vs custom modal div for popups

Compare the HTML dialog element with a custom modal div for popups: focus management, keyboard behavior, screen reader support and what to test before launch.

James HollowayNov 8, 2026
Get started

Your next lead is one line away.

Pick a design, make it yours and paste a single script tag. Every widget type is included, and you do not need a credit card to start.

<script src="https://cdn.widgetjar.com/wj-assets/embed.js" defer></script>