How to get position for fixed element without jquery?

mrsum picture mrsum · Jan 11, 2013 · Viewed 7.7k times · Source

Hello there

I have an element with fixed position, I can't detect position and must be use javascript clearly, without frameworks (jquery, mootools, etc).

Answer

Totty.js picture Totty.js · Sep 23, 2014

Use:

var boundingBox = node.getBoundingClientRect();

Check out the result, you have an object like this:

top    : 0,
right  : 0,
bottom : 0,
left   : 0,
width  : 0,
height : 0