Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6010283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:05:38+00:00 2026-05-23T02:05:38+00:00

Since Firefox doesn’t have innerText, I am using textContent to retrieve the text of

  • 0

Since Firefox doesn’t have innerText, I am using textContent to retrieve the text of the body of a document. However, textContent returns anything within noscript and script tags that are in the body (and maybe other tags, I’m not thoroughly sure), which means that textContent will look different that what is normally returned by innerText.

Is there an equivalent in Firefox that returns the same output as Chrome’s innerText function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:05:39+00:00Added an answer on May 23, 2026 at 2:05 am

    Edit

    Included filter to not get content of certain elements

    They are two different properties – one is defined in the W3C DOM 3 Core, the other is a Microsoft proprietary property that has been widely copied but has no open specification.

    Probably the best way to normalise the two is to not use them, instead use a DOM-walking routine that collects text nodes and creates a string. Use the same routine for both (all) browsers.

    // Get the text within an element
    // Doesn't do any normalising, returns a string
    // of text as found.
    function getText(element) {
      var text = [];
      var self = arguments.callee;
      var el, els = element.childNodes;
      var excluded = {
        'noscript': 'noscript',
        'script'  : 'script'
      };
    
      for (var i=0, iLen=els.length; i<iLen; i++) {
        el = els[i];
    
        // May need to add other node types here
        if ( el.nodeType == 1 && 
           !(el.tagName.toLowerCase() in excluded)) {
          text.push(self(el));
      
        // If working with XML, add nodeType 4 to get text from CDATA nodes
        } else if (el.nodeType == 3) {
    
          // Deal with extra whitespace and returns in text here.
          text.push(el.data);
        }
      }
      return text.join('');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since CS3 doesn't have a web service component, as previous versions had, is there
Since disable-output-escaping doesn't work on firefox (and isn't going to), whats the next best
I'm using Selenium IDE to occasionally test my web applications. However, since Selenium IDE
I have been using web parts on my site since ASP.NET 2.0 came out.
I'm unable to run any selenium tests since I updated Firefox to 3.6. Is
How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header
I'm using the Prototype (and script.aculo.us) javascript library - since it's what comes with
In firefox I have opened a locally stored file with the file:// protocol (file:///c:/temp/foo.html)
I have a Firefox plugin that adds some optional features to my web app.
I'm currently using Firefox 7.0.1. I've been working on a WYSIWYG editor and just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.