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 ...

+ Reply to Thread
Results 1 to 3 of 3

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

  1. Default 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?


  2. Default 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 };


  3. Default 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.


+ Reply to Thread

Similar Threads

  1. dropdownlist expand display width not control width
    By Application Development in forum DOTNET
    Replies: 0
    Last Post: 11-16-2007, 12:22 PM
  2. Measure pixel width of a container?
    By Application Development in forum Javascript
    Replies: 10
    Last Post: 09-22-2007, 02:00 PM
  3. Table width is always at 100%
    By Application Development in forum Javascript
    Replies: 1
    Last Post: 07-30-2007, 09:12 AM
  4. How to slice an image from width 180 to 150 pixel?
    By Application Development in forum DOTNET
    Replies: 1
    Last Post: 09-26-2006, 07:51 PM
  5. Tk::Table width/height
    By Application Development in forum Perl
    Replies: 1
    Last Post: 01-27-2005, 09:23 AM