2007-03-12

Javascipt: cross-browser event registration

var mozilla =document.getElementById && !document.all;
var ie =document.all;

function addevent( id, event, callback)
{
  if( ie)
      document.getElementById( id).attachEvent( 'on' +event, callback);
  else if( mozilla)
      document.getElementById( id).addEventListener( event, callback, true);
  else
    {
      // XXX???
    }
}