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).
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).
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
Does this help:
document.getElementById('id').offsetLeft // + window.scrollX
document.getElementById('id').offsetTop // + window.scrollY
You might want to look at : This Question
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent)
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
return [curleft,curtop];
}