0

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

4
  • 1
    Uncaught TypeError: Object <th>Game</th><th>Version</th><th>Size (GB)</th><th>Last Updated</th> has no method 'contains' Commented Feb 4, 2013 at 8:59
  • ah that makes sence, I wonder why in firefox this works but does not in chrome, i'll change it to match then should work. Commented Feb 4, 2013 at 9:05
  • Changing to match indeed fixed my issue, I should know this by now :P Commented Feb 4, 2013 at 9:07
  • "Scene able"? What are you talking about? Commented Feb 4, 2013 at 10:03

2 Answers 2

2

I'm getting errors on the filter:

Uncaught TypeError: Cannot read property 'innerHTML' of undefined

What I'm doing wrong?

for (i=0;i<50;i++)
{
    e = document.getElementsByTagName("tr")[i];
    z = e.innerHTML;
}
  • You don't know if you will have always 50 elements.
  • You are using incorrectly innerHTML
  • You are calling getElementsByTagName in every iteration

Solution:

var 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();
Sign up to request clarification or add additional context in comments.

Comments

1

see chrome developer tools for Errors ctrl+shift+j

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.