title: 'undefined' is not a function evaluating el.click() in Safari
body: <p>I would like to run a js function on pressing Enter button.
  Everything works great in IE, Chrome and Opera, but I get an error (explained below) in Safari.</p>
  
  <p>I need a <strong>pure Javascript</strong> solution, <strong>not jQuery</strong>.</p>
  
  <p>This is the <strong>function</strong>:</p>
  
  <pre><code>function pressSearch(e) {
      if (typeof e == 'undefined' &amp;&amp; window.event) {
          e = window.event;
      }
      var charCode = (e.which) ? e.which : 
                     ((e.charCode) ? e.charCode : 
                     ((e.keyCode) ? e.keyCode : 0));
      if (charCode == 13) {
          document.getElementById('enterSearch').click();
      }
  }
  </code></pre>
  
  <p>This is the <strong>HTML</strong>:</p>
  
  <pre><code>&lt;input type="text" id="searchKey" onkeypress="pressSearch(event)"&gt;
  &lt;div id="enterSearch"&gt;Search&lt;/div&gt; // This is the "button"
  </code></pre>
  
  <p>I get this <strong>error</strong>:</p>
  
  <pre><code>// Safari
  TypeError: 'undefined' is not a function 
      (evaluating 'getElementById('enterSearch').click()')
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong> I've fixed the Mozilla Firefox error.</p>