If you need to find the exact X/Y coordinates of a specific element for whatever reason, you can use the following function:

1
2
3
4
5
6
7
8
9
10
11
12
13
function getXY( oElement )
{
	var yReturnValue = 0;
	var xReturnValue = 0;
	while( oElement != null ) 
	{
		yReturnValue += oElement.offsetTop;
		xReturnValue += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	//At this point you can 'return' the values as well
	alert("Y : " + yReturnValue + " - X :" + xReturnValue );
}

Below is an example of how it can be used:

1
2
3
4
5
<!-- 
   This will give the X/Y coordinates of the hyperlink on the page
-->
 
<a href="http://www.google.com" onClick="getY(this);">Google</a><br>