JavaScript Events

来源:百度文库 编辑:神马文学网 时间:2024/06/13 07:54:45

JavaScript Events are items that transpire based on an action. A document event is the loading of an HTML document. A form event is the clicking on a button. Events are objects with properties.

Event Properties

  • x -Mouse x coordinate when the event happened.
  • y -Mouse y coordinate when the event happened.

JavaScript defines five types of events which are form, image, image map, link, and window events. Events are associated with HTML tags. The definitions of the events described below are as follows:

Form Events

  • blur - The input focus was lost.
  • change - An element lost the focus since it was changed.
  • focus - The input focus was obtained.
  • reset - The user reset the object, usually a form.
  • select - Some text is selected
  • submit - The user submitted an object, usually a form.

Image Events

  • abort - A user action caused an abort.
  • error - An error occurred.
  • load - The object was loaded.

Image Map Events

  • mouseOut - The mouse is moved from on top a link.
  • mouseOver - The mouse is moved over a link.

Link Events

  • click - An object was clicked.
  • mouseOut - The mouse is moved from on top a link.
  • mouseOver - The mouse is moved over a link.

Window Events

  • blur - The input focus was lost.
  • error - An error occurred.
  • focus - The input focus was obtained.
  • load - The object was loaded.
  • unload - The object was exited.



Event Association

Events are associated with HTML tags. The definitions of the events described below are as follows:

  • abort - A user action caused an abort of an image or document load.
  • blur - A frame set, document, or form object such as a text field loses the focus for input.
  • click - Happens when a link or image map is clicked on
  • change - Happens when a form field is changed by the user and it loses the focus.
  • error - An error happened loading a image or document.
  • focus - A frame set, document, or form object such as a text field gets the focus for input.
  • load - The event happens when an image or HTML page has completed the load process in the browser.
  • mouseOut - The event happens when the mouse is moved from on top of a link or image map
  • mouseOver - The event happens when the mouse is placed on a link or image map.
  • reset - The user reset the object which is usually a form.
  • submit - The user submitted an object which is usually a form.
  • unload - The object such as a framesed or HTML document was exited by the user.

The events for each HTML tag are as follows: