views:

16

answers:

1

I'm writing part of a web page that allows a user to build a table and fill it with information. In the course of building the table, the user will be adding additional columns with headers. I'd like to code it so when the combined width of all the headers causes one of them to wrap that the table columns switch to using vertical text (writing-mode: tb-rl). Is there any way, using JavaScript, to determine if the contents of a specific cell have wrapped?

Thanks, Spara

A: 

You could create a table with minimal height and your width. You could stick the innerhtml of the other element into your new table. If your new table's height is larger than you'd expect, the text has wrapped, causing the height to increase.

ItzWarty
My case is a little more complicated in that, by adding additional columns, the contents of the rest of the table might get "squished" and cause the height of the table to change. I've used your suggestion, but instead of looking at the table height, just look at the height of the row that has the column headers for a height change.
Sparafusile