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 6769205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:55+00:00 2026-05-26T15:09:55+00:00

I am having an issue with document.getElementByID in Mozilla. In the IE and Chrome

  • 0

I am having an issue with document.getElementByID in Mozilla. In the IE and Chrome my code is working well.

I have written the following code:

<script type="text/javascript">
function test(x, y) {
var text1 = document.getElementById('text1');
 for (var i = 0; i < x.length; i++) {
    text1.innerText += x[i]; // prints 12345
  }
   text1.innerText += "\ny: " + y; // prints y: 1,2,3,4,5
  }
</script>


 <body>
<form id="form1" runat="server">
<div>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</div>
<div id="text1"></div>
</form>
</body>

Can any one tell why this doesn’t work in FireFox?

  • 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-26T15:09:56+00:00Added an answer on May 26, 2026 at 3:09 pm

    I don’t think it’s the call to getElementById that’s the problem — if it is, then you didn’t give enough detail — but I can tell you that Firefox and some other browsers do not implement innerText. For those browsers, you need to work with textContent or text nodes directly.

    You can find out whether textContent is supported or not using feature detection:

    var textContentOrInnerText = "textContent" in document.body 
                                   ? "textContent" : "innerText";
    

    Then, you use this variable for the property access in your code:

    text1[textContentOrInnerText] += x[i];
    

    Feel free to shorten the variable to something you feel more comfortable with. Note that there are some minor differences in behaviour between both properties, but mostly you won’t notice them.

    textContent is the standards behaviour which is why I test for that first in my code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some IE7 (and presumably IE6) issues with the script. <script type=text/javascript> $(document).ready(function(){
I have this code: <script type=text/javascript> var currenttime = '<? print date(F d, Y
I have the following javascript and JsonResult. The issue I am having is the
I'm having an issue reading the below XML document in Chrome - nothing seems
I am having an issue regarding rotation of a pdf document in ipad. Have
I am having an issue with jquery in Chrome and Safari, the script is
Having an issue here that I have tried everything I can think of but
I am having an issue positioning a background image using the following jquery background
I have the following code that adds a file upload option to a div
I am having an issue with getting mod_rewrite rules working in .htaccess after moving

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.