event.target on Firefox

Make sure you define event as a formal parameter to the handler.

IE defines it globally, and Chrome defines it both in both places, so it works either way, but Firefox only defines it as a function parameter.

function up( e ) {
    //       ^-----------------------------------------------------+
    if( !e ) e = window.event; // <---needed this --- and this ->--+

    dragok = false;
    document.onmousemove = null;
    var x = e.target||e.srcElement; // <--- and these
    document.getElementById(x.id).style.left= 200 + "px" ;
    document.getElementById(x.id).style.top= 100 + "px" ;
} 

Leave a Comment