Possible Duplicate:
Calculate text width with Javascript
Alright, so here's what I am looking to see if can be accomplished. I want to take user submitted text (so.. variable length) and place it into a fixed width/height div. If the text will exceed the space allotted, I want to show as much as possible and place an ellipsis (...) at the end, as close to the boundary as I can.
So what I'm wondering... is it possible to tell how much space a certain block of text will take up (javascript)? I'm not looking to use a mono-spaced font, and even if I did I don't know if it would help much.
I'm beginning to wonder if there simply aren't too many variables to account for, and that I'll end up needing to do something less precise, such as outputting a fixed maximum of characters. But I wanted to see if anyone has accomplished something like this before, or if the general consensus was "not possible/not worth the effort." Thanks all!