Steffen Rusitschka wanted a cross-browser text-overflow:ellipsis, so he created it and told us all about it via Ellipsis or “truncate with dots” via JavaScript.

You can see it in action, or download the code. The main ellipsis function:

JAVASCRIPT:

  1.  
  2. function ellipsis(e) {
  3.   var w = e.getWidth() - 10000;
  4.   var t = e.innerHTML;
  5.   e.innerHTML = “<span>” + t + “</span>”;
  6.   e = e.down();
  7.   while (t.length> 0 && e.getWidth()>= w) {
  8.     t = t.substr(0, t.length - 1);
  9.     e.innerHTML = t + “…”;
  10.   }
  11. }
  12.  

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/143649222/ellipsis-or-%e2%80%9ctruncate-with-dots%e2%80%9d-via-javascript

Leave a Reply

You must be logged in to post a comment.



Site Navigation

Fatal error: Out of memory (allocated 52690944) (tried to allocate 716 bytes) in /home/tipsclub/public_html/ajaxgirl/wp-includes/functions.php on line 19