Alec_S 0 Newbie Poster

Hi
I'm struggling with JavaScript. I've found this bit of code:

//Get which URL was clicked on
 function getEvent (e) {
        var event = e || window.event;
        if( ! event.target ) {
          event.target = event.srcElement;
        }
       return event; 
      }

Run the function with code like this:
<a href="#fred" id="fred" onclick="alert(getEvent(event).target)">foo</a>

What do I change in this code, so I can process the return value for 'event.target'?

As it is, if I do a typeof on 'event' in 'return event', event is undefined etc.

Alec_S