window.event.target not working

Each row in my table consists of a number of columns. The first column contains a checkbox. I want to display details for the row if any column of the row has been clicked, except the first one. This code works fine in IE, but when I run it in Mozilla, I get "targ has no properties" error. It looks like window.event is not recognized because none of the alerts are displayed. Is it my browser settings?
Thanks.

<tbody onClick='doSelect(this);'>

    var targ;
    if (!e) {
       alert("1");
      var e = window.event;
       }
    if (e.target) {
      alert("2");
      targ = e.target;
    }
    else if (e.srcElement) targ = e.srcElement;
    if (targ.nodeType == 3) // defeat Safari bug
        targ = targ.parentNode;

    if ( targ.tagName == "INPUT" && targ.type == "checkbox" ) {
          return;
    }
EwSAsked:
Who is Participating?
 
cLFlaVAConnect With a Mentor Commented:


How are you calling the function?

Here is an example of how to use events and targets/srcElements:

function doIt(e) {
    var targ = e.target ? e.target : e.srcElement;
      alert(targ.tagName);
}



<table>
      <tbody onclick="doIt(event);">
            <tr><td>Row 1 Cell 1</td></tr>
      </tbody>
      <tbody onclick="doIt(event);">
            <tr><td>Row 2 Cell 1</td></tr>
      </tbody>
</table>
0
 
EwSAuthor Commented:
That was it! I was using 'this' instead of 'event' when calling the function. Thank you - I'm very grateful!
0
All Courses

From novice to tech pro — start learning today.