How is the "click to view more" function implemented?

Posted by bobo on Stack Overflow See other posts from Stack Overflow or by bobo
Published on 2010-06-07T14:18:47Z Indexed on 2010/06/07 14:22 UTC
Read the original article Hit count: 248

We often see websites that display first few lines of an article and then append ... [More] so that people who are interested in can click on it to view the full article.

To implement this functionality, we first need to find out where the article text should be cut to append the ... [More].

Since there must be some HTML/ CSS coupled with the article text, we must remember to ignore them when calculating the length of the text.

But there is something I just can't figure it out, if more than one language is mixed in the first few lines of the article text, the length of the text will be very difficult to calculate since the characters can be of variable length.

How should we solve this problem?

© Stack Overflow or respective owner

Related posts about web-development

Related posts about string-manipulation