I want to use JavaScript to slice this text so that it matches the object the text is in and add "..." at the end.
For example: JavaScript received data from a third-party web service and should put the text in a 200 x 300 px div. The length of the text varies, so let's say it takes up a lot more space than intended.
How to determine at what point the text will break through the border and prevent this by chopping the text and adding "..." at the end?
source share