JavaScript Events (Cont.)


onLoad and onUnload
The onLoad and onUnload events are triggered when the user enters or leaves the page. The onLoad event is often used to check the visitor’s browser type and browser version, and load the proper version of the web page based on the information.



   

onMouseOver and onMouseOut
onMouseOver executes JavaScript code when an onMouseOut event occurs; that is, once each time the mouse pointer moves over an object or area from outside that object or area. onMouseOut executes JavaScript code when a MouseOut event occurs; that is, each time the mouse pointer leaves an area or link from inside that area or link.



   

The example includes an onMouseOver event and an onMouseOut event that will run two JavaScript functions that will change between two images.



Demonstration
The following demonstration shows how the script of HTML and JavaScript is displayed on the Web.

     





      A guy walks into a bar and says, “Ouch.”    
      — Sam Richardson