public marks

PUBLIC MARKS from ycc2106 with tags code & tips

29 March 2006

16 March 2006

22 February 2006

Truncate HTML Text with JavaScript Automatically

This article describes what I think is a clever way of automatically truncating the text of a paragraph: * Truncate the text to a length of your choosing * Do not truncate in the middle of a word (only on a word boundary) * Keep the page search-engine friendly by publishing the complete non-truncated text * Add an ellipsis to the end of the truncated text * Make the ellipsis a link that expands the text to full length. Once expanded it cannot be collapsed again (but that functionality could be added just as easily) * Assumes that the content is plain text with no markup.