title: How to simulate a click with JavaScript?
body: <p>I'm just wondering how I can use JavaScript to simulate a click on an element.</p>
  <p>Currently I have:</p>
  <pre class="lang-js prettyprint-override"><code>function simulateClick(control) {
    if (document.all) {
      control.click();
    } else {
      var evObj = document.createEvent('MouseEvents');
      evObj.initMouseEvent('click', true, true, window, 1, 12, 345, 7, 220, false, false, true, false, 0, null );
      control.dispatchEvent(evObj);
    }
  }
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>&lt;a href=&quot;http://www.google.com&quot; id=&quot;mytest1&quot;&gt;test 1&lt;/a&gt;&lt;br&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
      simulateClick(document.getElementById('mytest1'));
  &lt;/script&gt;
  </code></pre>
  <p>But it's not working :(</p>
  <p>Any ideas?</p>