JavaScript
  Home arrow JavaScript arrow JavaScript Events
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

JavaScript Events
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2007-11-26

    Table of Contents:
  • JavaScript Events
  • OnBlur
  • OnChange
  • OnClick
  • OnDblClick

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    JavaScript Events


    (Page 1 of 5 )

    In our last article we left off with a glimpse of JavaScript Events. In this tutorial we are going to go through each one and learn how to use them to create more dynamic web sites. So slap on your seat belts and get your helmets ready. This is gonna be an action-packed episode.

    KAPOW!

    Let’s start off by reviewing our table full of Javascript Events:

     

    Event

    What Triggers the Event

    OnAbort

    Occurs when the loading of an image is interrupted

    OnBlur

    Occurs when an element loses focus

    OnChange

    Occurs when the user changes the content of a field

    OnClick

    Occurs when the user clicks an object

    OnDblClick

    Occurs when the user double clicks an object

    OnError

    Occurs when an error occurs while loading a document or an image

    OnFocus

    Occurs when an element has focus

    OnKeyDown

    Occurs when a keyboard key is pressed

    OnKeyPress

    Occurs when a keyboard key is pressed or held down

    OnKeyUp

    Occurs when a keyboard key is released

    OnLoad

    Occurs when a page or image has completed loading

    OnMouseDown

    Occurs when a mouse button is pressed

    OnMouseMove

    Occurs when the mouse is moved

    OnMouseOut

    Occurs when the mouse is moved off of an element

    OnMouseOver

    Occurs when the mouse is moved over an element

    OnMouseUp

    Occurs when the mouse button is released

    OnReset

    Occurs when the reset button is clicked

    OnResize

    Occurs when a window or frame is resized.

    OnSelect

    Occurs when text is selected

    OnSubmit

    Occurs when the submit button is clicked

    OnUnload

    Occurs when the user exits the page

    OnAbort

    As shown in the table above, the OnAbort Event occurs when the loading of an image is interrupted. When this occurs you may wish to alert the user in any number of ways. Below is an example of how to use a function with the OnAbort event.


    <html>

    <head>

    <script type="text/javascript">

    function noImage()

    {

    alert('There was an issue loading your image. Perhaps you are too ugly')

    }

    </script>

    </head>

    <body>

    <img src="your_photo.gif"

    onabort="noImage()">

    </body>

    </html>

    In the above code, we write a script that loads a photo named your_photo.gif. If the loading of the photo is aborted, it triggers a function we named noImage, which uses a pop-up alert box to display the following text: There was an issue loading your image. Perhaps you are too ugly.

    You could also have achieved the same affect much easier, but I wanted to show you how to call a function. The easier method would have been to write this:


    <html>

    <head>

    </head>

    <body>

    <script type="text/javascript">


    <img src="your_photo.gif"

    onabort=”alert('There was an issue loading your image. Perhaps you are too ugly')”>

    </script>

    </body>

    </html>

    This would end in the same result as our previous code.

    Supporting HTML tags: <img>

    Supporting Javascript Objects: image

    More JavaScript Articles
    More By James Payne


       · Hey, welcome to my article on Javascript Events, where we discuss some of the Events...
     

    JAVASCRIPT ARTICLES

    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...
    - Bulleted Menu of Links
    - Creating Click Loggers and Basic Markers wit...
    - Adding Pan Controls to Yahoo! Maps
    - Adding Zoom Controls to Yahoo! Maps
    - Working with Yahoo! Maps
    - Building Image Zooming Controls with the DOM...
    - Working with Multiple Graphics for a Zoom Ap...

    Iron Speed

    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway