how can i detect the height of a TD tag?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn Anderson

    how can i detect the height of a TD tag?

    Is there a way to detect the height of a TD tag?
  • kaeli

    #2
    Re: how can i detect the height of a TD tag?

    And on the day 7 Oct 2003 11:44:38 -0700, shawn@revealed. net enlightened
    us with <a170ce78.03100 71044.5723cf08@ posting.google. com>...[color=blue]
    > Is there a way to detect the height of a TD tag?
    >[/color]

    In recent browsers only, you can get the height of a table CELL (not a
    tag - tags don't have a height).

    Given the following cell:
    <td id="whatever">. ..</td>

    <script type="text/javascript">
    myVar = document.getEle mentById?docume nt.getElementBy Id
    ("whatever").ge tAttribute("hei ght"):0;
    </script>

    Browsers (older ones, like NN4) that do not support
    document.getEle mentById would get 0 as the value.


    --------------------------------------------------
    ~kaeli~
    Kill one man and you are a murderer. Kill millions
    and you are a conqueror. Kill everyone and you
    are God.


    ------------------------------------------------

    Comment

    • DU

      #3
      Re: how can i detect the height of a TD tag?

      kaeli wrote:
      [color=blue]
      > And on the day 7 Oct 2003 11:44:38 -0700, shawn@revealed. net enlightened
      > us with <a170ce78.03100 71044.5723cf08@ posting.google. com>...
      >[color=green]
      >>Is there a way to detect the height of a TD tag?
      >>[/color]
      >
      >
      > In recent browsers only, you can get the height of a table CELL (not a
      > tag - tags don't have a height).
      >
      > Given the following cell:
      > <td id="whatever">. ..</td>
      >
      > <script type="text/javascript">
      > myVar = document.getEle mentById?docume nt.getElementBy Id
      > ("whatever").ge tAttribute("hei ght"):0;
      > </script>
      >[/color]

      but here, there is no height attribute defined for the "whatever" cell,
      so myVar will hold null. Height is not a valid attribute in strict DTD
      anyway.

      OTOH, document.getEle mentById("whate ver").offsetHei ght will return the
      general pixel height of the cell.

      Tested and working in Opera 7.20, Mozilla 1.5RC2, MSIE 6 and NS 7.1.

      DU
      --
      Javascript and Browser bugs:

      - Resources, help and tips for Netscape 7.x users and Composer
      - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


      Comment

      Working...