Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tathastu871 opened this issue Nov 8, 2024 · 2 comments

Comments

@tathastu871
Copy link

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??

@annevk
Copy link
Member

annevk commented Nov 8, 2024

Mainly because popups are quite problematic in their design from a privacy perspective. They actively clash with this effort: https://privacycg.github.io/storage-partitioning/

So making improvements to popups with openers is not really in the end user's interest.

@tathastu871
Copy link
Author

Currently for local purpose, testing for popup permission i use this trickery

--> have installed any extension that prevent duplicate tabs
--> popupCheck() {
window.open().close();
win = window.open(location.href);
if (!win|| win.closed) alert('No popup Permission, check for browser notification to allow, or allow manually');
}
In case user allows popup the stale window will have same url as current
so extension will close duplicate previous tab

Also becase window.close() self if not allowed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants