Struppi: DOM Events Chrome und Opera

Beitrag lesen

Eventuel mit?

function doSomethingID(event)
  {
  var nav = navigator.userAgent;

if(document.addEventListener)
    {
    var clickID = event.target.getAttribute('id');
    alert('DOM Event Model: ' +clickID +' ' +nav );
    }

if(!document.addEventListener)
    {
    if(window.event)
      {
      var el  = window.event.srcElement;
      var clickID = el.getAttribute('id');
      alert('M$ Event Model: ' +clickID +' ' +nav);
      }
    }
  }


>   
  
Das geht einfacher:  
~~~javascript
  
function doSomethingID(event)  
{  
   if(!event) event = window.event; // Wobei ich nicht sicher bin, ob diese Zeile notwendig ist  
   var el = event.target || event.srcElement;  
   var clickID = el.id;  
}

Struppi.