screen{X,Y,Left,Top} use window location, not viewport - #45097
Conversation
|
Preview URLs (5 pages)
Flaws (2) Note! 4 documents with no flaws that don't need to be listed. 🎉 Found an unexpected or unresolvable flaw? Please report it here. URL:
External URLs (3)URL:
URL:
URL:
(comment last updated: 2026-09-02 01:05:23) |
|
cc @greggman |
|
lgtm. FYI screenY has the same issue with showing and hiding things like bookmark bars. |
|
Wait—@greggman do you know where in the spec does it say this property is based on the content (viewport, I assume)? The spec says:
Weirdly, it never gave a definition for client window; but its only other appearance is in So perhaps this is just a content bug, and we should replace everything that says "viewport" (which means |
|
maybe. It's a pretty ridiculous API. It had a purpose. Browsers apparently broke it and never bothered to make it useful again. I'd suggest removing the sample since it doesn't actually work. |
|
idk, it looks pretty useful to me 🤷 This example also works for me. The circle moves as you drag the browser window across the device screen. Sure, it's offset by showing/hiding toolbars/sidebars, but I don't think that subtracts from its usefulness in most cases. |
|
There's a bug in this demo that prevents the correct |
|
I’m curious what you think the use case is? To me the use case is to align with something relative to the screen. The center or one of the edges. It does’t work for that. Worse, if you’re a vertical tab user and you have the auto hide feature (common), it breaks even more |
|
mdn/dom-examples#393 should fix the bug in the demo. |
Well I can't speak for vertical tabs. But there's only an unobservable dimension change if the browser chrome dynamically changes. In the remaining cases, this demo works as intended. MDN is not in a good position to discuss whether a feature is "useful" anyway; we can only document what it does and you as a reader can figure out whether it fits your particular use case. If you think there's an unimplementable UX involving dynamic browser UI, you could raise the issue with CSSWG to have additional ways to measure, say, the viewport's position within the window. That would definitely be helpful for this demo, which, per the note I added, suffers exactly from this lack. |
|
that is not really my point though. The demo does not do what it claims to do What it claims to do
It does not keep the circle in the same physical position on the screen. And further, every browser puts the circle in a different place. chrome Screen.Recording.2026-09-02.at.12.41.01.mp4firefox Screen.Recording.2026-09-02.at.12.43.28.mp4safari Screen.Recording.2026-09-02.at.12.44.09.mp4 |
|
Yes, as I said, no behavior can be said about when the browser UI changes dynamically. I already added the following disclaimer:
This demo is only for when the browser UI stays constant. As I also said, I believe true fixed screen position is unattainable unless you can query the viewport's location within the window, and if that's what you'd like to see, it would be very helpful to ask in CSSWG. |
Even if the UI doesn't change dynamically. Set one window to have its tabs visible and another not. Then run such a demo in 2 windows. The 2 windows will not align. They used to, example from 2011 (video is newer, demo was written in 2011) |
Summary
Addresses #45048: No Browser Implements screenX, screenY according to the spec
Changed files
files/en-us/web/api/window/screenx/index.mdValidation
git diff --check: passedFixes #45048