Using % on a table width, is it possible to get the width in pixel size? - Javascript
This is a discussion on Using % on a table width, is it possible to get the width in pixel size? - Javascript ; If you have an HTML table defined like so
<table border="1" width="100%" height="100%">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Is it possible using JavaScript to ...
-
Using % on a table width, is it possible to get the width in pixel size?
If you have an HTML table defined like so
<table border="1" width="100%" height="100%">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Is it possible using JavaScript to return the width and height pixel
counts for the width and height of the table?
-
Re: Using % on a table width, is it possible to get the width in pixel size?
On Aug 1, 11:10 am, RMZ <Jeremy.De...> wrote:
> If you have an HTML table defined like so
>
> <table border="1" width="100%" height="100%">
> <tr>
> <td>row 1, cell 1</td>
> <td>row 1, cell 2</td>
> </tr>
> <tr>
> <td>row 2, cell 1</td>
> <td>row 2, cell 2</td>
> </tr>
> </table>
>
> Is it possible using JavaScript to return the width and height pixel
> counts for the width and height of the table?
If you are willing to use prototype.js (Prototype library
http://prototypejs.org/api), you can simply call
$('tableid').getDimensions(); and it will return an object { width: 0,
height: 0 };
-
Re: Using % on a table width, is it possible to get the width in pixel size?
On Aug 1, 2:02 pm, jamie... wrote:
> On Aug 1, 11:10 am, RMZ <Jeremy.De...> wrote:
>
> > If you have an HTML table defined like so
>
> > <table border="1" width="100%" height="100%">
> > <tr>
> > <td>row 1, cell 1</td>
> > <td>row 1, cell 2</td>
> > </tr>
> > <tr>
> > <td>row 2, cell 1</td>
> > <td>row 2, cell 2</td>
> > </tr>
> > </table>
>
> > Is it possible using JavaScript to return the width and height pixel
> > counts for the width and height of the table?
>
> If you are willing to use prototype.js (Prototype libraryhttp://prototypejs.org/api), you can simply call
>
> $('tableid').getDimensions(); and it will return an object { width: 0,
> height: 0 };
Assuming the table does not have a display style of "none", you can
use the offsetWidth and offsetHeight properties of the table element.
That is what Prototype sends back for displayed elements. This will
save you 70K of extra page weight.
Similar Threads
-
By Application Development in forum DOTNET
Replies: 0
Last Post: 11-16-2007, 12:22 PM
-
By Application Development in forum Javascript
Replies: 10
Last Post: 09-22-2007, 02:00 PM
-
By Application Development in forum Javascript
Replies: 1
Last Post: 07-30-2007, 09:12 AM
-
By Application Development in forum DOTNET
Replies: 1
Last Post: 09-26-2006, 07:51 PM
-
By Application Development in forum Perl
Replies: 1
Last Post: 01-27-2005, 09:23 AM