title: addEventListener not triggering when used in a Chrome extension
body: <p>I'm trying to make a Chrome extension that will search different cache databases for a given page. However, it's not working as I expect it to.</p>
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
  
  var x;
  var img = document.getElementsByTagName(&quot;img&quot;);
  for(x in img) {
      img[x].addEventListener('click',openPage, false);
  }
  
  function openPage(event) {
      alert(&quot;clicked&quot;);
      var e = event.target;
      switch(e.alt) {
      case &quot;WayBack Machine&quot;:
          chrome.tabs.update(tab.id, { url: &quot;http://wayback.archive.org/web/*/&quot; + tab.url });
          break;
      
      case &quot;Google Cache&quot;:
          if(tab.url.substring(0, 5) == &quot;http:&quot;)
              chrome.tabs.update(tab.id, { url: 'http://webcache.googleusercontent.com/search?q=cache:' + tab.url.substr(7) });
          else if(tab.url.substring(0,6) == &quot;https:&quot;)
              chrome.tabs.update(tab.id, { url: 'http://webcache.googleusercontent.com/search?q=cache:' + tab.url.substr(8) });
          break;
  
      case &quot;Yahoo Cache&quot;:
          // Need the yahoo cache url
          break;
  
      case &quot;Bing Cache&quot;:
          chrome.tabs.update(tab.id, { url: &quot;http://cc.bingj.com/cache.aspx?q=&quot; + tab.url + &quot;&amp;d=4572216504747453&amp;mkt=en-US&amp;setlang=en-US&amp;w=802790a9,218b61b8&quot; });
          break;
      
      case &quot;Gigablast&quot;:
          chrome.tabs.update(tab.id, { url: &quot;http://www.gigablast.com/get?q=&quot; + tab.url + &quot;&amp;c=main&amp;d=70166151696&amp;cnsp=0&quot; });
          break;
  
      case &quot;CoralCDN&quot;:
          chrome.tabs.update(tab.id, { url: tab.url + &quot;.nyud.net&quot; });
          break;
      
      default: // Webcite
          // Need to send a request, this won't do
          chrome.tabs.update(tab.id, { url: &quot;http://webcitation.org/query&quot; });
          break;
      }
  
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;img src=&quot;Google Cache.png&quot;, alt=&quot;WayBack Machine&quot; class=&quot;button&quot; id=&quot;WayBack Machine&quot; height =&quot;40px&quot; /&gt;
  &lt;img src=&quot;Google Cache.png&quot;, alt=&quot;Google Cache&quot; class=&quot;button&quot; id=&quot;Google Cache&quot; height =&quot;40px&quot; /&gt;
  &lt;img src=&quot;Google Cache.png&quot;, alt=&quot;Yahoo Cache&quot; class=&quot;button&quot; id=&quot;Yahoo Cache&quot; height =&quot;40px&quot; /&gt;
  &lt;img src=&quot;Google Cache.png&quot;, alt=&quot;Bing Cache&quot; class=&quot;button&quot; id=&quot;Bing Cache&quot; height =&quot;40px&quot; /&gt;
  &lt;img src=&quot;Google Cache.png&quot;, alt=&quot;Gigablast&quot; class=&quot;button&quot; id=&quot;Gigablast&quot; height =&quot;40px&quot; /&gt;
  &lt;img src=&quot;Google Cache.png&quot;, alt=&quot;CoralCDN&quot; class=&quot;button&quot; id=&quot;CoralCDN&quot; height =&quot;40px&quot; /&gt;
  &lt;img src=&quot;Google Cache.png&quot;, alt=&quot;Webcite&quot; class=&quot;button&quot; id=&quot;Webcite&quot; height =&quot;40px&quot; /&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p>However, it does not even <code>alert();</code> When I try the code in a jsfiddle.net, it works: <a href="http://jsfiddle.net/RZ2wC/" rel="nofollow noreferrer">http://jsfiddle.net/RZ2wC/</a></p>
  <hr />
  <p>Here is my manifest.json:</p>
  <pre><code>{
    &quot;name&quot;: &quot;gCache&quot;,
    &quot;version&quot;: &quot;1.1.5&quot;,
    &quot;description&quot;: &quot;View the Google Cache of a page&quot;,
  
    &quot;browser_action&quot;: {
      &quot;default_icon&quot;: &quot;icon.png&quot;,
      &quot;default_text&quot;: &quot;Google Cache version of this page&quot;,
      &quot;default_popup&quot;: &quot;cacheList.html&quot;
    },
  
    &quot;permissions&quot;: [
      &quot;tabs&quot;
    ]
  }
  </code></pre>
  <hr />
  <p>Any help would be greatly appreciated. On this question and any bugs that you see in my code that I haven't gotten to yet.</p>