I understand that writing cross browser javascript is important. But, why has Firefox just made my life a little crappier? While it is running my script without a hitch in windows it has decided to not run the code in firefox for the mac. to be fair this is ok and I almost expected it; as we all do i open the debug window to follow the errors. what no errors? anywhere? Im now left pissing in the proverbial wind.
Humph.
:: UPDATE ::
Ok, i fixed it!
lets assume you have filled a variable full of childNodes, in this case the child nodes we are after are DIV tags. You want to loop through them. should be simple right?
using the javascript below works in firefox for windows.
var Collection = HTMLElement.childNodes;
for (var i=0; i <= Collection.length -1; i++) {
alert( Collection(i).innerHTML );
}
not so in Firefox for the mac, not in OS X 10 Anyways.
you have to use the following, replace the parenthesis with square brackets haha that simple, this one had me blowing a fuse.
note. the check for the DIV tags too, for some reason mac fox adds everything to the collection including textRanges and so on, what this means as that each item may not be a DIV.
var Collection = HTMLElement.childNodes;
for (var i=0; i <= Collection.length -1; i++) {
if (ingDivs[i].tagName == ‘div’) {
alert( Collection[i].innerHTML );
}
}
obviously further checks could be taken such as to ensure we have anything in our Collection in the first place but that wasnt the scope of this post so dont be smart asses and tell me this.
I hope this helps somone.
J
Recent Comments