Defining JavaScript Event Object
<p>Why am I getting an error for this piece of code?:</p>

<pre><code>function catchevent() 
{
    eventSrcID=(event.srcElement)?event.srcElement.id:'undefined';

    eventtype=event.type;

    status=eventSrcID+' has received a '+eventtype+' event.';
}
</code></pre>

<p>Firefox says that <code>event</code> is not defined. Actually, this is copied from <a href="http://www.webdevelopersjournal.com/articles/jsevents3/jsevents3.html" rel="nofollow">here</a> and it clearly says that it is for IE5.  I use Firefox 3.6.13 on Ubuntu.</p>

<p>My Question is not why it doesn't work on my browser.  Instead, is there a way to define <code>event</code> object, as suggested by the link, that would work for my browser?</p>

<p><strong>UPDATE</strong></p>

<p>Why isn't this working</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script&gt;
function catchevent( e ) {
      // reference the proper event object
    var e = e || window.event;

      // reference the proper target
    var srcElem = e.target || e.srcElement; //line no 9

      // get the id of the target
    var eventSrcID = srcElem.id;

    alert(eventSrcID);
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;a id="link1" href="#" onclick="catchevent()"&gt;link1&lt;/a&gt;
    &lt;a id="link2" href="#" onclick="catchevent()"&gt;link2&lt;/a&gt;
    &lt;a id="link3" href="#" onclick="catchevent()"&gt;link3&lt;/a&gt;

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

<p>For this i am still getting error on line no 9</p>

<pre><code>e is undefined
[Break On This Error] var srcElem = e.target || e.srcElement; 
</code></pre>

<p>Now how do I need to pass <code>event</code> object on <code>catchevent()</code> or is there some mistake? please suggest.</p>
