title: Is it possible to trigger a link's (or any element's) click event through JavaScript?
body: <p>I'm writing some JavaScript code that needs to fire the <code>click</code> event for a link. In Internet Explorer I can do this  </p>
  
  <pre><code>var button = document.getElementById('myButton');
  button.click();
  </code></pre>
  
  <p>But this doesn't work in Firefox, and I assume any other browser. In Firefox, I've done this  </p>
  
  <pre><code>var button = document.getElementById('myButton');
  window.location = button.href;
  </code></pre>
  
  <p>I feel like this is not the best way to do this. Is there a better way to trigger a <code>click</code> event? Preferably something that works regardless of the type of element or the browser.</p>