This is an odd one, for whatever reason, getting the children of an element doens’t work in Camino browser. Works in all other browsers. Anyone know how to fix this? Google is no help 🙁
var site_result_content = document.getElementById(content_id);
site_child_nodes = site_result_content.children;
alert('started');
for(i=0;i<site_child_nodes.length;i++) {
alert('cycle1');
document.getElementById(site_child_nodes[i].id).className = 'tab_content';
ShowHide(site_child_nodes[i].id,'hidden');
}
In this case, the started alert is called, but the cycle1 isn’t.
Use
childNodesinstead.childrenstarted out as a proprietary property that in IE, whereaschildNodesis in the W3C DOM spec and is supported by every major browser released in the last decade. The difference is thatchildrencontains only elements whereaschildNodescontains of all types, in particular text nodes and comment nodes.I’ve optimized your code below. You should declare all your variables with
var, including those used in loops such asi. Also,document.getElementById(site_child_nodes[i].id)is unnecessary: it will fail if the element has no ID and is exactly the same assite_child_nodes[i]otherwise.