whatwg / whatwg/html

Way to close stale window with null reference that browser opens after a blocked popup was allowed by user

Open
#10,751 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
9.4k
Forks
3.2k
PR merge metrics
PR metrics pending

Description

What is the issue with the HTML Standard?

window.open() Returns null Reference after a Popup is allowed by user gesture

Currently there is no api to check for popup blocker is active, or quering popup/redirect Permissions are given

In order to check for popup blocker in place
trickery like

window.open().close(); let ref = window.open(location.href, 'newtarget')
is what i and other use, since both calls are made simultaneously within one execution cycle it triggers popup blocker if webpage is denied any popup permissions
What this does is, it prevent second window from opening

But Problem is,

When popup is blocked "Always allow" notification is seen and user allows it,
It opens the second window in above call
but it has null reference "STALE WINDOW"
We can't close it!!!!

Even executing, newRef = window.open('', 'newtarget') Wont return reference as new window's, target Name has been reset ''

User had to manually close this stale window
Or
Ignore the allow popup notification and manually allow popup permission by going to settings or from page info lock icon

This doesnt provide seamless user experience

This is not about bypassing blocker or something

Its about!!!
Any way to "CLOSE STALE WINDOW" programatically, after a popup is allowed,

Is been years in web development, why no one still did something about this??

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the reported window.open().close(); followed by window.open(location.href, 'newtarget') sequence and the behavior after the user allows the popup. Determine what change to the HTML Standard could provide a usable reference or another way to close the stale window, and define done as resolving that behavior without requiring manual browser settings.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.