title: why it can add active to the a label?
body: <pre><code>&lt;ul id="nav"&gt;
      &lt;li&gt;&lt;a href="/about/"&gt;About Us&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/contact/"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/archives/"&gt;Our Archives&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/free/"&gt;Free Stuff&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>js code:</p>
  
  <pre><code>function setActive() {
    aObj = document.getElementById('nav').getElementsByTagName('a');
    for(i=0;i&lt;aObj.length;i++) {
      if(document.location.href.indexOf(aObj[i].href)&gt;=0) {
        aObj[i].className='active';
      }
    }
  }
  </code></pre>
  
  <p>i can't understand it well.
  1, first <code>aObj</code> is get all the a label in nav</p>
  
  <p>2,<code>aObj.length</code> equals 4, </p>
  
  <p>3,<code>document.location.href.indexOf(aObj[i].href</code> what's this line meanig?</p>
  
  <p>4,why the loop can add <code>active</code> to the current a?</p>