Hi guys,
i have a new problem/idea. I would like to shorten a long string, so that it will fit into a div with predefined width and height. One obvious solution is, to just shorten a string to some predefined number of characters, that will approximately fit into my box. OK, what i don’t like about that idea, is that if i dont use monospace font and if i put 100 of “iiii..” in the string i will end up with half empty box, on the other side, 100s of “mmmm…” are going to overflow my box. So i was wondering if it is somehow possible to detect, when my box is starting to overflow, so that i can cut my string there. And also, i would save a lot of time with a script like that, because i can use it in different sized boxes without any tuning….just plug and play.
So, is anything like that possible with JS or do i live in a fantasy world? ?