0

I am playing with lots of AJAX requests, AJAX with GET/POST. I have got Firebug 1.9.1. It's showing me warning saying:

Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead

I am not understanding what it means. I also searched. Everyone telling how to suppress that warning but I need to know why this warning is appearing?

Colin Brock
  • 21,267
  • 9
  • 46
  • 61
Debugger
  • 544
  • 1
  • 9
  • 25
  • Some of your html / script might be helpful in giving an answer ;) Firebug will typically tell you what line of javascript something failed on. From the look of that error and what you hinted at, I would guess your JS is trying to reference a DOM element by ID when that ID is being used by multiple page elements (an easy mistake to make if you use AJAX to grab a template multiple times, and don't take active steps to make the IDs in that template globally unique) – Will Buck Feb 14 '12 at 16:22

1 Answers1

3

A little searching revealed that your question has already been answered. You are referencing an element that is in the global scope. Internet Explorer will automatically put elements with an id in the global scope, but other browsers do not do this.

If you want to reference an element, do so like this:

var e = document.getElementById('yourId'); //Get your element.
e.style.visibility = 'hidden'; //Do something with it.

If you want further help, you need to post code with your question.

Community
  • 1
  • 1
Justin Helgerson
  • 24,900
  • 17
  • 97
  • 124