title: Same window.addEventListener For 2 html files
body: <p>Hello Everyone I have this problem that is just bugging me and I cant get it figured out. I looked everywhere and couldnt find an answer.</p>
  
  <p>I have 2 html files and 1 external javascript file....</p>
  
  <p>This is the first html file</p>
  
  <pre><code>&lt;!doctype html&gt;
  
  &lt;head&gt;
      &lt;title&gt;.....&lt;/title&gt;
      &lt;script src="externalJsFile"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;input type="button" value="button1" id="button1"&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;html&gt;
  </code></pre>
  
  <p>here is my second html file that links to the same external javsascript file</p>
  
  <pre><code>&lt;!doctype html&gt;
  
  &lt;head&gt;
      &lt;title&gt;.....&lt;/title&gt;
      &lt;script src="externalJsFile"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;input type="button" value="button2" id="button2"&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is my external javascript file</p>
  
  <pre><code>window.addEventListener("load", setFunctions, false);
  
  
  function setFunctions() {
      var button1 = document.getElementById("button1");
      var button2 = document.getElementById("button2");
  
      button1.addEventListener("click", sayHello, false);
      button2.addEventListener("click", sayHello, false);
  }
  
  
  function sayHello() {
      alert("hello");
  }
  </code></pre>
  
  <p>When I visit each html page to click the button to see the hello popup box it only works in one of the pages. In the javascript if i switch around the order of the event listeners on the buttons then the popup will only work on the other page now!! someone please help!! Do I need separate external javascript files for each html page when a window event listener is used???</p>