title: JavaScript addEvent function
body: <p>I have an <code>addEvent</code> function:</p>
  
  <pre><code>function addEvent(elem, event, func ) {
     if (typeof (window.event) != 'undefined')
          elem.attachEvent('on' + event, func);
     else 
         elem.addEventListener(event, func, false);
  }
  
  &lt;a href="#" id="link"&gt;link&lt;/a&gt;
  </code></pre>
  
  <p>and I'm trying to add the following to <code>window.onload</code>:</p>
  
  <pre><code>addEvent(window, 'load', function (){
     // add another event
     var link= document.getElementById('link');
     addEvent(link, 'click', function () {alert('Hi'); });
  });
  </code></pre>
  
  <p>My question is: why does the <code>link</code> event not work?</p>