home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap16 / dun16_6.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  1005 b   |  31 lines

  1. <HTML>
  2. <HEAD>
  3.   <TITLE>Handling mouseOver and mouseOut Events</TITLE>
  4.  
  5.   <SCRIPT>
  6.     function highlight(callingElement)
  7.     {
  8.       if (!callingElement.contains(event.fromElement))
  9.         callingElement.style.backgroundColor = "yellow";
  10.     }
  11.  
  12.     function unhighlight(callingElement)
  13.     {
  14.       if (!callingElement.contains(event.toElement))
  15.         callingElement.style.backgroundColor = "white";
  16.     }
  17.   </SCRIPT>
  18. </HEAD>
  19.  
  20. <BODY BGCOLOR=white>
  21. <P ID=text onMouseOver="highlight(this);" onMouseOut="unhighlight(this);">
  22.   When the cursor moves from normal text within a paragraph to
  23.   <B>bold text</B>, a <TT>mouseOut</TT> event is generated by the
  24.   <TT>P</TT> element and a <TT>mouseOver</TT> event is generated by
  25.   the <TT>B</TT> element. This causes the paragraph highlighting to
  26.   blink. The cursor, however, has not moved out of the boundaries
  27.   of the <TT>P</TT> element, simply onto one of its child elements.
  28. </P>
  29. </BODY>
  30. </HTML>
  31.