Click to See Complete Forum and Search --> : Dynmic reading of <DIV> tag coordinates.


s_bramley
05-12-2003, 08:24 PM
Is it possible to determine the coordinates of a <div> tag without actually stating them within a stylesheet?

If so how do I set the <div> up?

pyro
05-12-2003, 08:36 PM
Try using offsetLeft and offsetTop, like this:

<html>
<head>
<script language="javascript" type="text/javascript">

function getpos() {
alert ("Top:"+document.getElementById("mydiv").offsetTop+"\nLeft:"+document.getElementById("mydiv").offsetLeft);
}

</script>

</head>

<body onload="getpos();">
<br/>
<br/>
<br/>
<div id="mydiv"></div>
</body>
</html>

s_bramley
05-12-2003, 08:50 PM
thank you so much. This is exactly what I was lookiong for.

pyro
05-12-2003, 09:30 PM
Cool... You're welcome!