Is there a way using javascript to detect the absolute position of where you are positioned on a monitor? For example Intersection Observer can tell you if your element is within the viewport of the browser, but it cannot tell you if the browser is halfway off the users monitor, and your element is outside of an actual persons view.
Asked
Active
Viewed 1,133 times
1
-
I don't think JavaScript knows anything about the physical screen, no. All it knows about is the page it's in and the browser environment. For security reasons web pages have very limited access to information about the device the browser is running on – ADyson May 02 '19 at 21:20
-
This might be of some help to start off with https://stackoverflow.com/questions/49003290/detect-if-browser-window-is-maximized-and-at-default-100-zoom – imvain2 May 02 '19 at 21:23
1 Answers
2
You can find the position of the element using getBoundingClientRect
var x = document.getElementById("elementId").getBoundingClientRect().x;
var y = document.getElementById("elementId").getBoundingClientRect().y;
//Your element position
var position = [x, y];
If your element is off the viewport, it would have negative values depending on its position from top-left.

Sandeep P
- 133
- 5