On Oct 9, 8:57 am, Andrew Dupont <[EMAIL PROTECTED]> wrote:
[...]
> You want Tobie's "getInnerText" function [1]. We should think about
> putting this into Prototype at some point.
>
> [1]http://tobielangel.com/2006/10/18/extending-prototype-getinnertext

Interesting, but it relies on browser sniffing and proprietary
properties.  Consider:

function getText(el)
{
  var x = el.childNodes;
  var txt = '';
  var node;

  for (var i=0, len=x.length; i<len; ++i){
    node = x[i];

    if (3 == node.nodeType) {
      txt += node.data;
    } else if (1 == node.nodeType){

      if (node.tagName && node.tagName.toLowerCase() != 'script') {
        txt += arguments.callee(node);
      }
    }
  }
  return txt.replace(/\s+/g,' ');
}


Stripping scripts might be helpful, or not. The above uses more lines
of code, however that is insignificant in a library function.


--
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to