aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Table width calculation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Table width calculation" Watch "Table width calculation" New topic

Table width calculation

Anu Jv

Joined: Apr 02, 2003
Posts: 14
I have a table with width set in percentage. Now I need to know the width of the table in pixels. Is this possible
<table width=100% border=0 id="MyTable">
<tr><td>Sample text</td></tr>
If I try "alert(document.getElementById("MyTable").width);" I get 100% but I need the width in pixels as the pixels occupied by the table will differ when the window is resized
Susilo Saja
Ranch Hand

Joined: May 27, 2003
Posts: 91
You can use the "offsetWidth" property
Anu Jv

Joined: Apr 02, 2003
Posts: 14
Thanks. It works fine
It is sorta covered in the JavaRanch Style Guide.
subject: Table width calculation
Similar Threads
equivalent of frames in struts
table cells not aligning
EJB Table, please correct me and contribute
Dynamic table generation in jsp
width of HTML table cell