find the displayed size of a <td>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • alex.pedwysocki@gmail.com

    find the displayed size of a <td>

    Having trouble googling this one.

    I have a dynamically generated table that I'd prefer not to set sizes
    for.

    Is there any way to know the size that the browser is using to display
    this cell?

    The problem: adding an image (using javascript) that is too large
    causes the width of one column to expand. If I have text in another
    column it could be squeezed, thus taking up more vertical space. Then
    the whole page will become longer and, in doing so, will offset the
    view provided by the browser.

    In extreme cases, using large tables, this can cause the view to be
    offset by many screen lengths. Whatever data was being looked at is
    long gone down the page somewhere. This is not a good user
    experience.

    If my javascript knows the width the cell is being displayed to it can
    compensate by picking an image of the right size.

    If I can't do that, does anyone have another idea? Thanks!
  • Gregor Kofler

    #2
    Re: find the displayed size of a &lt;td&gt;

    alex.pedwysocki @gmail.com meinte:
    Having trouble googling this one.
    >
    I have a dynamically generated table that I'd prefer not to set sizes
    for.
    >
    Is there any way to know the size that the browser is using to display
    this cell?
    >
    The problem: adding an image (using javascript) that is too large
    causes the width of one column to expand. If I have text in another
    column it could be squeezed, thus taking up more vertical space. Then
    the whole page will become longer and, in doing so, will offset the
    view provided by the browser.
    >
    In extreme cases, using large tables, this can cause the view to be
    offset by many screen lengths. Whatever data was being looked at is
    long gone down the page somewhere. This is not a good user
    experience.
    >
    If my javascript knows the width the cell is being displayed to it can
    compensate by picking an image of the right size.
    Perhaps clientWidth might help.
    The clientWidth read-only property of the Element interface is zero for inline elements and elements with no CSS; otherwise, it's the inner width of an element in pixels. It includes padding but excludes borders, margins, and vertical scrollbars (if present).


    I suppose some restrictions apply.

    Gregor


    --
    http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
    http://web.gregorkofler.com ::: meine JS-Spielwiese
    http://www.image2d.com ::: Bildagentur für den alpinen Raum

    Comment

    Working...