I’m using this code
var anchors = document.getElementsByTagName("a");
to detect anchors in HTML document. There are a lot of such tags. But alert(anchors.length) reports 0. It seems strange. Do you know what could be the problem?
I’m using this code in firefox extension
var Highlighter = {
...
highlightLinks: function() {
var anchors = document.getElementsByTagName("a");
...
}
window.addEventListener("DOMContentLoaded", function(e) { Highlighter.highlightLinks(); }, false);
thank you
In a Firefox extension, if you add code to the browser via an overlay, then
documentis the browser document (browser.xul) not the web page’s document. You can get the web page viacontent.document.