Searching...
Tuesday 2 October 2012

JavaScript Events

10:46 pm

JavaScript Events

                        Events are actions that can be detected by javascript.every on a webpage has contain events which can trigger javascript functions.

Examples of events:

1.       A mouse click
2.       A webpage or an image loading.
3.       Mousing over a hotspot.
4.       Onload and onunload    : 
                                                The onload and onunload events are triggered when the user enters or leaves the page.
5.       Onfocus, onblur and onchange.
6.       On submit
7.       Onmouseover and onmouseout
8.       Onkeyup and onkeydown

Example programe :    events.html

                  <html>
                  <head>
                <script type=”text/javascript”>
                Function fun1()
                {
                  Document.img1.src=”images/image1.jpg”;
                }
               Function fun2()
                 {
                    Document.img1.src=”images/image2.jpg”;
               }
            Function fun3()
                {
                Document.img2.width=200;
                Document.img2.height = 200;
               }
            Function fun4()
             {
               Document.img2.width=30;
               Document.img2.width=30;
            }
            </script>
          </head>
           <body>
              <img src=”images/image3”   name=”img1”  onMouseOver=”fun1()”   width=”200” height=”200” onMouseOut=”fun2()”>
    <br><br><br>
         <img src=”images/image4”  name=”img2”   width=”30” height=”30’ onMouseOver=”fun3()” onMouseOut=”fun4()”>
     <//body>
    </html>

0 comments:

Post a Comment