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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:26:32+00:00 2026-06-04T20:26:32+00:00

I’m trying to call document.getElementsByTagName , and I’m getting back undefined as a result,

  • 0

I’m trying to call document.getElementsByTagName, and I’m getting back undefined as a result, no matter what parameter I pass. (Even if I pass “*”.)

I tried Googling for it, but all the search results were about elements of the getElementsByTagName result array being undefined. What I’m getting is undefined as the result itself, and it’s driving me up the wall.

Does anyone know what can cause this? (Using Firefox 12.0. In Chrome I get the expected results.)

EDIT: OK, here’s sample code:

function buttonClick(){
   var xhr = new XMLHttpRequest();
   var msg = document.getElementById('message');
   var buttons = document.getElementsByTagName("button");
   var button, i;
   for (i = 0; i < buttons.length; ++i){
      button = buttons[i];
      msg.removeChild(button);
   }

   xhr.onreadystatechange = function() {
        if(xhr.readyState == 4){
            handleResult(xhr.responseText, msg);
        }
   };
   xhr.open("POST", location.href, true);
   xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
   xhr.send("cmd=MyCommand");
}

And the getElementsByTagName always returns undefined, whether I trace it in Firebug’s Script tab or call it from the Console tab. (Also in Firebug, since this seems to be confusing people. Apparently there are way too many consoles floating around.).

As proof, here’s what I’ve been getting when I tried to use the Firebug console:

>>> document.getElementsByTagName("button");
undefined
>>> msg.getElementsByTagName("button");
undefined
>>> msg.getElementsByTagName
getElementsByTagName()
>>> msg.getElementsByTagName("BUTTON");
undefined
>>> msg.getElementsByTagName("*");
undefined
>>> document.getElementsByTagName("*");
undefined
>>> document.getElementsByTagName("body");
undefined

The markup is (or ought to be) irrelevant. It’s a valid, well-formed HTML page with some buttons and other elements on it. This JS function is attached to the onclick of one of the buttons. But it looks something like this:

<html xmlns="http://www.w3.org/1999/xhtml"><head>
blah
</head>
<body>
<script type="text/javascript" src="/myJS.js"></script>
<div id="page-container">
   <div id="message"><button onclick="buttonClick();">Button 1</button><button onclick="ButtonClick2()">Button 2</button></div>

</div>

</body></html>
  • 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-06-04T20:26:34+00:00Added an answer on June 4, 2026 at 8:26 pm

    edit:

    This is a bug in firebug and is fixed by upgrading to 1.10.0a7


    Because it is impossible for this method to return undefined, there are 2 possibilities:

    • Your debugging tools are lying to you
    • document.getElementsByTagName is not referencing the original host object. It should print
      function getElementsByTagName() {[native code]} when referenced in console.

    You should be able to reliably to see if it’s in fact undefined (in firefox) with this:

    delete window.alert;
    window.alert(buttons);
    

    The delete is a NOOP if window.alert is already referencing the original host object, otherwise
    it will restore it.

    If it alerts undefined, you should be able to do

    delete document.getElementsByTagName
    

    to restore the host object reference.

    All console references here refer to the built in Web Console that comes with firefox by default.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

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.