Connecting Tech Pros Worldwide Help | Site Map

Width of a String

Afshin
Guest
 
Posts: n/a
#1: Jul 20 '05
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
Guest
 
Posts: n/a
#2: Jul 20 '05

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.0312080920.3b83867f@posting.google.c om...[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]


Closed Thread