Saturday, November 21, 2009

Javascript - Passing events

<script language="javascript" type="text/javascript">
  function hide(elementId, event) {
     document.getElementById(elementId).style.visibility = 'hidden';
     alert(event.type); //type of event because of which this function was called
     /*firefox: used to get the element that handled this method... the exact caller.
         <div id="outer" onmouseout="hide('outer', arguments[0])">
            <div id="inner"></div>
     //firefox: In this case "outer" will be returned   
        //firefox: the exact element that gave rise to this event. "inner" from above example.
     <span onmouseout="hide('elementId', arguments[0])">Something</span>

More event object properties are at this website.

No comments: