Reputation: 164
I have some custom javascript code which works great in firefox, however in chrome it seems to not respond at all, the page is located here: http://wiki.tf2clan.co.uk/index.php/games/sizes
I would appreciate any input as to why chrome doesn't like this, and/or any alternative code snippets
Upvotes: 0
Views: 1829
Reputation: 17471
I'm getting errors on the filter:
Uncaught TypeError: Cannot read property 'innerHTML' of undefined
for (i=0;i<50;i++)
{
e = document.getElementsByTagName("tr")[i];
z = e.innerHTML;
}
getElementsByTagName
in every iterationvar nodes = document.getElementsByTagName("tr").childNodes;
//Iterating through TR childs
for(i=0; i<nodes.length; i++) {
alert(nodes[i]);
}
Alternative:
If you are not a Javascript expert, I recommend to use jQuery to manage the DOM elements, it's cross browser and very documented. For example, you could do something like this with jQuery instead the whole for
loop:
$('tr > td:not(:contains("+filter_text+")')).hide();
Upvotes: 2