What I use in this case is:
$('test').textContent || $('test').innerText
If textContent is defined, it is used. if it isn't, innerText is used.
This would be a lot faster than stripping tags.
The only drawback I can think of is that sometime you may get an
undefined instead of an empty string (which would be equivalent to
false).
Eric
On Apr 12, 9:35 pm, Rüdiger Plantiko <[email protected]>
wrote:
> Hi TJ,
>
> > > I get the number 4711 in IE with $("test").innerText and in FF with $
> > > ("test").textContent - does Prototype provide a browser-independent
> > > abstraction for this?
>
> > Hopefully you get the *string* "4711" rather than the number 4711
> > (unless you parse it). :-)
>
> You are right, in a posting every word is important, in order
> to avoid misunderstandings. So, yes: I am getting the string, not the
> number.
>
> > ... innerHTML ...
>
> yeah, if the document structure guarantees to me that the element in
> question only contains a text node, then I could use innerHTML
> equivalently
> to innerText/textContent.
>
> > Element.addMethods({
> > text: function(element) {
> > if (!(element = $(element))) return;
> > return element.innerHTML.stripTags();
> > }
>
> > });
>
> thanks for the reference to String.stripTags() - I hadn't realized the
> existence of
> such a function before.
>
> - Regards,
> Rüdiger
--
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 [email protected].
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.