I have a webpage with an elastic layout that changes its width if the browser window is resized.
In this layout there are headlines (h2) that will have
h2
Just like @acSlater I couldn't find something for what I needed so I rolled my own. Sharing in case anyone else can use:
ellipsisIfNecessary(mystring,maxlength);
trimmedString = ellipsisIfNecessary(mystring,50);