Lurker News
Two browser windows (acting as socket clients) communicate their:

- Screen dimensions - (screen.width, screen.height)
- Window dimensions - (window.innerWidth, window.innerHeight)
- Window X/Y position - (window.screenX, window.screenY)
...or whichever calculation works best for you.
The original work by Bjorn Staal https://twitter.com/_nonfigurativ_/status/172732259457002734 used localStorage, but I found sockets more fun, because if tweaked a bit, this can be shared with friends.
Here's a demo of how it works and the codebase: https://github.com/Momciloo/fun-with-sockets/

Comments (129) 42 threads

Earlier comments
hoosieree#
what fresh pop-up/pop-under hell even is this?!? I specifically asked for not that
worldsayshi#
Okay this one is actually cool. I'm hoping it's not totally one-off scripted but it's fun either way. :)
jakegmaths#
Here's something similar I made yesterday. Just view source of the controlling page and the pop-up pages for how it works (single page with inline vanilla JavaScript and no npm install nonsense). Just uses postMessage(). https://cms-compsci.deno.dev/mrgordon/window/
gmueckl1 reply#
Does this work on Wayland?
HellsMaddy1 reply#
Tested on Sway with both Firefox and Chromium. Resizing works (no surprise) but the position doesn't work. window.screenX/Y always return 0.
account42#
Good. Websites have no business knowing anything of the world outside the viewport.

Load more comments