I am trying to develop a Firefox extension. The following code:
var divList = document.getElementsByTagName("div") ;
Components.utils.reportError("num of divs = " + divList.length) ;
Always says:- num of divs = 0.
I don't understand what is the mistake that I am making in this simple piece of code. When I replace "div"
with "*"
, I always get a value around 1100 on any webpage.
Not sure what is the difference in the extension context, but it might have to do with namespaces - https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName. What is the tag of the first of 1100 elements you get when using "*"?