-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Modernized version of window.open() API #7485
Comments
We could also make it throw an exception if the popup is blocked, instead of returning null. |
FWIW, we had discussed making https://w3c.github.io/ServiceWorker/#clients-openwindow It seemed it might have avoided some of the mistakes of |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
The current window.open() does indeed have a quite a few odd quirks, so perhaps a new API would be reasonable. But before adding anything it would be good to figure out if similar features should be added also to anchor elements (with target attribute) or form elements (with target attribute). And what other ways there are to open new windows, at least Clients.openWindow() (which is rather weird itself, since it has so limited features). |
I shared related explorations in 2020. I wonder if returning a promise would help avoid sync access to pre-initialized window properties (e.g screenX|Y, outerWidth|Height rely on async user agent, operating system, and window manager functionality crbug.com/1434097) It might also help avoid accessing the initial about:blank document (e.g. crbug.com/1434136) These loose ideas may be infeasible or increase friction, I'm just brainstorming. |
In the triage calls we've briefly discussed @smaug----'s suggestion of additionally augmenting
What remains is the functionality of the OP's How this
I think this is fairly separable from the JavaScript API proposal, so I don't think it's a blocker for moving forward with that. But I'm glad we checked to make sure, before forging ahead. On the question of the return value: we discussed this also a bit in the triage call. There was indeed interest in having it return a promise, but no clarity about when the promise would resolve. Ideas included:
On the connection to Service Worker's
So in conclusion, I think this proposal could move forward. |
This came up in our TAG review of Document Picture-in-Picture, as the reasons for this whole new API (instead of just an
It may be good to take these into account when designing a It had come up a while before, when a I think we're largely aligned on the goals:
Now, on to the specifics:
Yes! Dictionary instead of weird encoded strings is a low hanging fruit here.
Makes sense, it's a bit weird, and there are other ways to address these use cases.
Agreed.
I suspect the vast majority of use cases do need opener access, but making it explicit does improve security.
From a quick read that seems reasonable, but could you elaborate on what this would mean for this API?
Would it instead make sense to make the
Yes!
Also low-hanging fruit.
It does seem reasonable to have separate methods for opening a new tab or creating a popup.
Makes sense. I don't see a plan for supporting feature detection. Simply throwing when these methods are called is not sufficient, as authors need to be able to know what options are supported before opening any windows. |
window.open()
is full of legacy design mistakes. Here is a proposal for what, IMO, it should look like:In particular such a clean slate would:
no-referrer
(the latter is possible via today'snoreferrer
string option)about:blank
URLswindow.open()
has where it's impossible to add a fourth argument dictionary since there is legacy code that doeswindow.open(url, name, features, "replace")
and"replace"
throws an error when converting to a dictionary.The text was updated successfully, but these errors were encountered: