title: "Uncaught TypeError: undefined is not a function" while using str.indexOf function
body: <p>I get this message in the cosole: <code>Uncaught TypeError: undefined is not a function</code>  and it's literally making me crazy! There is no mistakes that I can see, but maybe someone else can help me.</p>
  
  <pre><code>var nav = document.getElementsByClassName('navigation');
  
  console.log(nav);
  console.log(nav[0]);
  var nav_e = nav[0];
    //var searched = nav[0].search('&lt;a href="forumdisplay.php?fid=11"&gt;Deck - Lab&lt;/a&gt;');
  
    if (nav_e.indexOf('&lt;a href="forumdisplay.php?fid=11"&gt;Deck - Lab&lt;/a&gt;') &gt; -1) {
  
      var list = document.getElementsByClassName('post_body');
      var xmlhttp = new XMLHttpRequest();
  
      var pbelement_encoded = '';
      var pbelement = ''
  
      for (i = 0; i &lt; list.length; i++) {
        var element = list[i];
  
        xmlhttp.onreadystatechange=function() {
  
          if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
  
            var result = xmlhttp.responseText;
            var result2 = result.replace(/fhvjgvghepoapeoaareupo/g,'');
  
  
            element.innerHTML = (xmlhttp.responseText.replace(/fhvjgvghepoapeoaareupo/g,''));
          }
        }
  
        pbelement_encoded = encodeURIComponent(element.innerHTML);
        pbelement = 'pb='+pbelement_encoded;
  
        //alert(pbelement);
  
        xmlhttp.open("POST","http://theepicsurge.altervista.org/PostAnalyzer.php",false);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
        xmlhttp.send(pbelement);
      }
    }
  }
  </code></pre>
  
  <p>The error ocures in the first <code>if</code> statement: <code>if (nav_e.indexOf('&lt;a href="forumdisplay.php?fid=11"&gt;Deck - Lab&lt;/a&gt;') &gt; -1) {</code></p>
  
  <p>I also tried replacing the <code>nav_e.indexOf</code> with <code>nav_e.search</code>, but it doesn't change anything</p>