Detect which link was clicked? Always returns undefined. What's wrong?
<p>I am trying to detect which of the first 3 links is being clicked on by outputting the links ID.</p>

<p>It always returns <code>undefined</code>.</p>

<p>What's wrong?</p>

<pre><code>&lt;html&gt;
  &lt;head&gt;

    &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;

    &lt;script type="text/javascript"&gt;
      window.onload = function() {

         onclick = function() {
            alert(this.id);
            return false;
         }
          }
    &lt;/script&gt;
  &lt;/head&gt;

  &lt;body&gt;

    &lt;a class="a" name="a" id="1" href="#"&gt;---1---&lt;/a&gt;
    &lt;a class="a" name="a" id="2" href="#"&gt;---2---&lt;/a&gt;
    &lt;a class="a" name="a" id="3" href="#"&gt;---3---&lt;/a&gt;

    &lt;a href="#"&gt; normal link &lt;/a&gt;

  &lt;/body&gt;
&lt;/html&gt;
</code></pre>
