Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Using % on a table width, is it possible to get the width in pixel size?

Reply
Thread Tools

Using % on a table width, is it possible to get the width in pixel size?

 
 
RMZ
Guest
Posts: n/a
 
      08-01-2007
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?

 
Reply With Quote
 
 
 
 
jamie.ly@gmail.com
Guest
Posts: n/a
 
      08-01-2007
On Aug 1, 11:10 am, RMZ <(E-Mail Removed)> 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 };

 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      08-01-2007
On Aug 1, 2:02 pm, (E-Mail Removed) wrote:
> On Aug 1, 11:10 am, RMZ <(E-Mail Removed)> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
Is it possible to get the width of table cell(s) that have been dynamically built via JavaScript? douglasc Javascript 0 11-21-2003 06:56 PM
Re: Pixel size of individual Pixel Tom Thackrey Digital Photography 2 09-14-2003 04:17 PM
Hot pixel vs. stuck pixel Abrasha Digital Photography 5 09-02-2003 04:49 PM
Re: resized image in table extends table width to original image width Sean Jorden HTML 1 08-19-2003 08:59 AM



Advertisments