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
heavyset_go#
Thanks
heavyset_go#
Thanks
sshh12#
Reminds me of a cool demo of this for playing pong with browser windows http://stewd.io/pong/
Agingcoder2 replies#
Could someone explain what this means ? ( I’m not even sure I understand the gif on the GitHub page ) I just see windows seemingly sharing data.
NL807#
I think it's some kind of multiple client, single server setup. The windows are the individual clients, which pass screen geometry info to the server. The server then serves content to clients with different layout that makes content appear as a single object across multiple windows.
et-al#
The core of the trick isn't the window-window communication as much as using browser APIs to expose the window coordinates.
doctorhandshake1 reply#
Cool! Feels like whichever window has focus, that window’s rectangle should draw on top.
benj111#
Isn't that just to illustrate that it isn't just transparency?

Load more comments