get the size of a table or cell

Discussion in 'Javascript' started by chris, Aug 17, 2004.

  1. chris

    chris Guest

    is there a way by using html or javascript or anything else for that matter
    to detirmine the actual height or width of a table or cell

    for example if i only set the height to 100 and the data in the cell needs a
    higher cell it expands to suit - i want to find out what the actual height
    ends up ??

    thanks for your help

    chris
    chris, Aug 17, 2004
    #1
    1. Advertising

  2. chris wrote:

    > is there a way by using html or javascript or anything else for that matter
    > to detirmine the actual height or width of a table or cell
    >
    > for example if i only set the height to 100 and the data in the cell needs a
    > higher cell it expands to suit - i want to find out what the actual height
    > ends up ??


    Most browsers (Netscape 6/7, Mozilla, IE 4/5/6, Opera 7 for sure) allow
    you to read the offsetWidth/offsetHeight of an element e.g.
    <td id="aCell">...</td>

    var cell;
    if (document.getElementById) {
    cell = document.getElementById('aCell');
    }
    else if (document.all) {
    cell = document.all['aCell'];
    }
    if (cell) {
    alert(cell.offsetWidth + 'x' + cell.offsetHeight);
    }

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Aug 17, 2004
    #2
    1. Advertising

  3. chris

    Denzil Guest

    "chris" wrote in message news:
    > is there a way by using html or javascript or anything else for that matter
    > to detirmine the actual height or width of a table or cell


    Hi,

    The following link from MSDN gives all the DHTML Object Model
    properties that are related to the dimension and location of elements.
    Worth a see.

    [Measuring Element Dimension and Location]
    http://msdn.microsoft.com/library/d...r/dhtml/reference/properties/clientheight.asp

    Cheerz,
    Denzil
    Denzil, Aug 17, 2004
    #3
  4. chris

    Denzil Guest

    Denzil, Aug 18, 2004
    #4
  5. chris

    noone Guest

    "Will Gittoes" <> skrev i en meddelelse
    news:1092735001.91079@ftpsrv1...
    > chris wrote:
    > > is there a way by using html or javascript or anything else for that

    matter
    > > to detirmine the actual height or width of a table or cell
    > >
    > > for example if i only set the height to 100

    >
    > Make sure you tell it if this is 100 PIXELS (px), PERCENT (%) etc...
    > This is important!
    >
    > and the data in the cell needs a
    > > higher cell it expands to suit - i want to find out what the actual

    height
    > > ends up ??
    > >
    > > thanks for your help
    > >
    > > chris
    > >
    > >

    >
    > No, not that I know of, sorry. Annoying, isn't it?


    Actually, if you can set a property, then you can also read a property.
    Anything else wouldn't make much sense.

    Robert
    noone, Aug 20, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bill
    Replies:
    6
    Views:
    506
  2. Mike

    Table cell bgcolor size ?

    Mike, Oct 29, 2003, in forum: HTML
    Replies:
    2
    Views:
    712
    Jukka K. Korpela
    Oct 29, 2003
  3. Phillip Roncoroni
    Replies:
    14
    Views:
    1,069
    Toby A Inkster
    Apr 5, 2004
  4. chris
    Replies:
    5
    Views:
    5,618
    Will Gittoes
    Aug 20, 2004
  5. John Dalberg
    Replies:
    4
    Views:
    769
Loading...

Share This Page