Hi Kathleen,
Here is something you can use to get the width of your table. The function
doIt() calculates the width of the table in two ways: first it extracts
just the width property of the table. You can get a reference to your table
by using the getElementById method of the document object. Another way to
get to the table is to use DOM collections like childNodes to get to your
table.
The second method iterates through the column collection (rows[0].cells)
and asks each column for its width. The total for all columns is then returned.
Please note that this is not a very cross-browser solution. getElementById
was introduced in IE 5 and in Netscape 6, so it won't work on older browsers.
Hope this helps,
Imar
<html>
<head>
<title></title>
<script language="JavaScript">
<!--
function doIt()
{
alert('Total width is ' +
document.getElementById("tblTest").width);
var myTable = document.getElementById("tblTest");
var iNumCols = myTable.rows[0].cells.length;
var iTotalWidth = 0;
for (var i = 0; i < iNumCols ; i++)
{
var iMyWidth =
(myTable.rows[0].cells[i].width * 1.0);
iTotalWidth = iTotalWidth + iMyWidth;
}
return ('All columns summed ' + iTotalWidth);
}
//-->
</script>
</head>
<body>
<table id="tblTest" width="600">
<tr>
<td id="col1" width="100">
1
</td>
<td id="col2" width="200">
2
</td>
<td id="col13" width="300">
3
</td>
</tr>
</table>
<form name="frmTest" id="frmTest">
<input type="button" value="Click" id="btnTest"
name="btnTest" onclick="JavaScript:alert(doIt());">
</form>
</body>
</html>
At 02:44 PM 7/20/2001 -0400, you wrote:
>I have a table that has 3 rows and 10 columns. Table is being opened via a
>javascript function into a new window. However, I want the window
>specifically sized to match the size of my table. How do I find the
>height and width of my table in pixels?