Question

I'm developing Firefox extension. For some statistics I need actual display coordinates of DOM Element inside browser.

I can get coordinates of:

  1. Required DOM Element inside viewport by calling it's getBoundingClientRect() (this takes scrolling into account, perfect).
  2. The Window (ChromeWindow) itself by checking it's screenX & screenY properties.

But when I call getBoundingClientRects() of browser, I get it coordinates excluding the size of window frame & borders drawn by system (tested on Mac). How to also count their (borders & frames) size independently for different operating systems?

Is it possible at all?

Was it helpful?

Solution 2

Found comment inside sources of Firefox that it's not possible.

OTHER TIPS

How about window.screenX or window.mozInnerScreenX? Respectively screenY, etc.

If that doesn't work, you could probably use js-ctypes to call OS-functions, which i guess are able to let you calculate the border size. On Windows you'd use GetWindowRect and GetClientRect as explained in this thread. No idea how this is possible in OSX though, but there surely is a way ...

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top