There's several web APIs for browser window positioning, like screenX/Y[0] (which is what OP uses), which allows for those classic pop-up based browser games from over a decade ago, like Browser Ball.[1]
[0]: demo: https://mdn.github.io/dom-examples/screenleft-screentop/
For this to work, the browser itself would have to know where its window is placed on the screen. Not all platforms provide such information.