How to compute absolute x, y coordinate of a HTML element using Java Script?
Web Development
1
Posts
1
Posters
0
Views
1
Watching
-
The method I have coded does not work well when the element is wrapped within multiple DIV elements? function calcXY (obj) { var x = y = 0; while (obj != null && obj.nodeType == 1) { // alert (obj.nodeName + ' ' + obj.offsetTop); x+= obj.offsetLeft; y+= obj.offsetTop; obj = obj.parentNode; } alert ('Location of obj is ' + x + ',' + y); } Can anybody help me with a suggestion or a better method? B2C