Width of a String

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

    Width of a String

    Hi,

    I am trying to create a very long dynamic document with fixed width
    for the cells of my table iin HTML, I need to truncate some of the
    information that I display to fit in the table.

    As the document is very long I can not use the offsetwidth
    functionality of the cell because then the user will see the
    information being truncated, which is not desireable, I was wondering
    if there is any way of calculating the width of the text displayed in
    the "risky" rows on the fly before the whole document gets rendered.

    I tried to display the information in the row and then try to truncate
    it right away after using the offsetwidth to see the width of the text
    in pixel, but this is not working as the offsetwidth needs the whole
    document to be rendered before being able to calculate the exact
    value.

    If anybody has any idea of how to do this on the fly I would
    appreciate yor help.

    Thanks

    Afshin
  • Mike

    #2
    Re: Width of a String

    Try doing something clever like setting the visibility of the table to
    hidden, then calculate your offsetWidth values on the onload event for the
    document. After you make your adjustments, set the visibility to visible.



    "Afshin" <afshin_shirazi @yahoo.com> wrote in message
    news:1ae4c805.0 312080920.3b838 67f@posting.goo gle.com...[color=blue]
    > Hi,
    >
    > I am trying to create a very long dynamic document with fixed width
    > for the cells of my table iin HTML, I need to truncate some of the
    > information that I display to fit in the table.
    >
    > As the document is very long I can not use the offsetwidth
    > functionality of the cell because then the user will see the
    > information being truncated, which is not desireable, I was wondering
    > if there is any way of calculating the width of the text displayed in
    > the "risky" rows on the fly before the whole document gets rendered.
    >
    > I tried to display the information in the row and then try to truncate
    > it right away after using the offsetwidth to see the width of the text
    > in pixel, but this is not working as the offsetwidth needs the whole
    > document to be rendered before being able to calculate the exact
    > value.
    >
    > If anybody has any idea of how to do this on the fly I would
    > appreciate yor help.
    >
    > Thanks
    >
    > Afshin[/color]


    Comment

    Working...