codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  table position problem  Blackpard at 03:51 on Saturday, July 17, 2004
 

Hi Group,
I've found it's difficult to find the absolute position of table in browsers. Here is an example:

<html>
<head>
<title>Test Position</title>
<script language='javascript'>
function objById(id){
return document.getElementById(id);
}

function showPosition(id){
var obj = objById(id);
var xx = obj.offsetLeft;
var yy = obj.offsetTop;
var h = obj.offsetHeight;
for(obj = obj.offsetParent; obj != null; obj = obj.offsetParent){
xx += obj.offsetLeft;
yy += obj.offsetTop;
}

alert(id + ":" + xx + "," + yy + "," + h);
}
</script>
</head>
<body onload=showPosition('table1') style='margin:0'>
<table id='table1' width=60% height=200 bgcolor=gray align=center style='position:relative;left:0;top:20;'>
<tr><td>this is a table</td></tr>
</table>
</body>
</html>

The showPosition('table1') gives: 0,20,200. The left postion is obviosly wrong with 'align=center'.

It's appreciated greatly for any help!












CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Learning VB(Looking for opinions)
•  How to open a .DOC file in MS-Word thru a link
•  Export database`s data into a CSV file in jspscript.....
•  Adding values to text field from popup - JavaScript
•  How to insert Javascript within Javascript ?
•  Event Close Browser botton
•  setting alphanumeric code
•  syntax error in insert statement .please help me solve it
•  Re: need code to export html report to excel and autosave with current date as filenaem


Recent Articles
Simple Thumbnail Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)
Function to Return Alpha Characters Only
The OSI Reference Model - A Clear and Concise Illustration !


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004