title: onclick() not working in safari
body: <p>The below code works fine on IE7 but not in Safari(5.0.5). If possible, I want to avoid using jQuery. The goal is for this functionality to work on iPad but right now testing with desktop safari. Please let me know if you have any ideas on getting it to work both on IE and Safari.<br>
     
      </p>
  
  <pre><code>&lt;div id="test" &gt;&lt;/div&gt;
  &lt;script&gt;
    function attachCallback(node) {
      node.onclick = function() {   
        alert("coming here");
      } ;
    }  
    var retrybutton = document.createElement("img");
    retrybutton.src = "test.png";
    retrybutton.alt = "retry";
  
    retrybutton.setAttribute("id","retrybutton");
    attachCallback( retrybutton ) ;
  
    var a = document.getElementById("test");
    a.appendChild(retrybutton);
    // testing without using retrybutton
    var test = document.getElementById("retrybutton");
    test.click();
  &lt;/script&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Update: Debating whether to go with "onmouseup" or something like below [<strong>Thanks Andres</strong>!! I'm not able to add comments]</p>
  
  <pre><code> if (Prototype.Browser.IE) {
     document.getElementById("retrybutton").click(); 
   } else { // from question link in comment
     var event = document.createEvent("HTMLEvents");
     event.initEvent("click", true, true);
     document.getElementById('retrybutton').dispatchEvent(event);
   }
  </code></pre>