price quote

Register/ Signup

Login

Essay Samples

Essay Topics

How to Write Guide

How to Write An Essay

Essay Help

Research Papers

Research Paper Topics

Book Review

Blog

JavaScript Tutorial

why choose us

email us

Agent Signup
Free PR Checker
home buttonour services buttonplace order buttonwhy choose us buttoncontact us button
place order to get custom essay, custom term paper, custom research paper, thesis, disserationsign up to receive free and custom essays, term paper, research paper, thesispromise to provide quality essays, term paper, research paper, thesisearn money affiliate agent programfree sample essays, term paper, research paper
Our Prices

Flash Order: (8 Hours)

$39/page Order Now

Rush Order: (2 Days)

$29/page Order Now

Normal Order: (5 Days)

$25/page Order Now

Economic Order: (14 Days)

$20/page Order Now

Super Saver: (2 Months)

$15/page Order Now

Order Now
Limited Time Discount
Our Services
Essay Writing Services
Essay Help
Custom Essay & Term Paper Writing
Research Dissertation
Admission Documents
Editing & Proof Reading
Computer Applications
Web Design
How to Write Essays
How to an Write an Essay
How to Write a Book Report
How to Write a Thesis
Free Essay Samples
Abortion
Book Review: Get to Work
Film Review-Sicko
Sigmund Freud
Essays Topics
Application Essay
Argumentative Essay
Love Essay
Persuasive Essay
Buying Custom Essays
Buy Essay
Buy a Term Paper
Buy a Research Paper
Buy a custom essay

JavaScript Events

  • Events are actions that can be detected by JavaScript.
  • Every element on a web page has certain events which can trigger JavaScript functions.
  • Examples of events:
    • A mouse click
    • A web page or an image loading
    • Mousing over a hot spot on the web page
    • Selecting an input box in an HTML form
    • Submitting an HTML form
    • A keystroke

Event Handlers

  • Below is a list of the attributes that can be inserted into HTML tags to define event actions.
  • FF: Firefox, N: Netscape, IE: Internet Explorer

Attribute

The event occurs when...

FF

N

IE

onabort

Loading of an image is interrupted

1

3

4

onblur

An element loses focus

1

2

3

onchange

The user changes the content of a field

1

2

3

onclick

Mouse clicks an object

1

2

3

ondblclick

Mouse double-clicks an object

1

4

4

onerror

An error occurs when loading a document or an image

1

3

4

onfocus

An element gets focus

1

2

3

onkeydown

A keyboard key is pressed

1

4

3

onkeypress

A keyboard key is pressed or held down

1

4

3

onkeyup

A keyboard key is released

1

4

3

onload

A page or an image is finished loading

1

2

3

onmousedown

A mouse button is pressed

1

4

4

onmousemove

The mouse is moved

1

6

3

onmouseout

The mouse is moved off an element

1

4

4

onmouseover

The mouse is moved over an element

1

2

3

onmouseup

A mouse button is released

1

4

4

onreset

The reset button is clicked

1

3

4

onresize

A window or frame is resized

1

4

4

onselect

Text is selected

1

2

3

onsubmit

The submit button is clicked

1

2

3

onunload

The user exits the page

1

2

3

onload and onUnload

  • Triggered when the user enters or leaves the page.
  • 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.
  • Both the onload and onUnload events are also often used to deal with cookies that should be set when a user enters or leaves a page. For example, you could have a popup asking for the user's name upon his first arrival to your page. The name is then stored in a cookie. Next time the visitor arrives at your page, you could have another popup saying something like: "Welcome John Doe!".

onFocus, onBlur and onChange

  • onFocus, onBlur and onChange events à validation of form fields.

onChange Event

  • checkEmail() function will be called whenever the user changes the content of the field:

<input type="text" size="30" id="email" onchange="checkEmail()">

onSubmit Event

  • onSubmit event à validate ALL form fields before submitting it.
  • checkForm() will be called when the user clicks the submit button in the form. If the field values are not accepted, the submit should be cancelled.
  • checkForm() returns either true or false. If it returns true the form will be submitted, otherwise the submit will be cancelled:

<form method="post" action="xxx.htm"
onsubmit="return checkForm()">

onMouseOver and onMouseOut.

  • create "animated" buttons
  • An alert box appears when an onMouseOver event is detected:

<a href="http://www.w3schools.com"
onmouseover="alert('An onMouseOver event');return false">
<img src="w3schools.gif" width="100" height="30">
</a>