PDA

View Full Version : table position



whatever
07-20-2002, 10:44 PM
is there a way to determine a table's position? I'm generating dynamic tables on top of layers using <div>, so i need to know the position of certain tables relative to the browser window. Like if its possible to find how many pixels the table is from the left and top edges of the browser.

Thanks!

mouse
07-20-2002, 10:55 PM
You can determine the <div's position using absolute positioning like so...

<style>
div#bob{
position: absolute;
top:100px;
left100px
}
</style>

<div ID="bob">content</div>

OR

<div style="position:absolute;top:100px;left:100px">content<div>

Either giving the same result; a layer 100 pixels from both top and left. The first would enable you to define the co-ordinates through an external *.css file or through styling in the headers. :)

Graeme Hackston
07-21-2002, 05:15 PM
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/measuring.asp

Graeme Hackston
07-21-2002, 05:26 PM
This might give you a better idea

<html>
<head>
<title></title>
<script>
onload = function() {
var top = document.getElementById("table").offsetTop;
var left = document.getElementById("table").offsetLeft;
alert("left "+left+" px");
alert("top "+top+" px");
}
</script>
</head>
<body>
<table id="table" border="1">
<tr>
<td></td>
</tr>
</table>
</body>
</html>