find the displayed size of a <td>

A

alex.pedwysocki

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!
 
G

Gregor Kofler

(e-mail address removed) 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.
http://developer.mozilla.org/en/docs/DOM:element.clientWidth

I suppose some restrictions apply.

Gregor
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top