The purpose of these functions is to find the absolute X and Y co-ordinates of an HTML element. They work well in both Internet Explorer and Firefox

function getPositionX(objx) {
var curleft = 0;
if (objx.offsetParent) {
while (1) {
curleft += objx.offsetLeft;
if (!objx.offsetParent) {
break;
}
objx = objx.offsetParent;
}
} else if (objx.x) {
curleft += objx.x;
return curleft;
}
return curleft;
}

function getPositionY(objy) {
var curtop = 0;
if (objy.offsetParent) {
while (1) {
curtop += objy.offsetTop;
if (!objy.offsetParent) {
break;
}
objy = objy.offsetParent;
}
} else if (objy.y) {
curtop += objy.y;
return curtop;
}
return curtop;
}

var cursorX = getPositionX(obj);
var cursorY = getPositionY(obj);

Hope this code will help you …

 Leave a Reply

(required)

(required)


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2014 Developers Corner Suffusion theme by Sayontan Sinha