Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
innerText vs textContent
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ngan Pham  
View profile  
 More options Oct 23, 5:15 pm
From: Ngan Pham <nganp...@gmail.com>
Date: Fri, 23 Oct 2009 14:15:58 -0700
Local: Fri, Oct 23 2009 5:15 pm
Subject: innerText vs textContent

Hey guys,
Unless I'm mistaken, there seems to be cross browser incompatibility issue
with innerText and textContent.  innerText is IE (and everyone else I
believe), and textContent is Firefox (only, i believe).  In anycase,
wouldn't it make sense for Prototype to smooth this out?

Element.getText() perhaps?


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kangax  
View profile  
 More options Oct 23, 7:14 pm
From: kangax <kan...@gmail.com>
Date: Fri, 23 Oct 2009 16:14:14 -0700 (PDT)
Local: Fri, Oct 23 2009 7:14 pm
Subject: Re: innerText vs textContent
On Oct 23, 5:15 pm, Ngan Pham <nganp...@gmail.com> wrote:

> Hey guys,
> Unless I'm mistaken, there seems to be cross browser incompatibility issue
> with innerText and textContent.  innerText is IE (and everyone else I
> believe), and textContent is Firefox (only, i believe).  In anycase,
> wouldn't it make sense for Prototype to smooth this out?

> Element.getText() perhaps?

That's actually one big can of worms. Here's a full explanation, if
you're interested — http://stackoverflow.com/questions/1359469/innertext-works-in-ie-but-...

Most robust solution is actually not `textContent` and not
`innerText`, but recursive iteration of children (text) nodes. However
that could be "slow", depending on a context where it is to be used.
It is, of course, possible to feature test all known discrepancies and
craft fast, yet compliant implementation, but the size of such
solution would be rather humongous (see, for example, one of my
(incomplete) attempts — http://groups.google.com/group/comp.lang.javascript/msg/d1574256dea74077).

As always, it's all about context. If you care about consistent
results, go for recursive iteration or innerHTML + regex tag stripping
(remember that regex would still be fragile). If, on the other hand,
it's all about speed — use textContent/innerText and take care of
discrepancies as needed.

--
kangax


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google