Sams Teach Yourself JavaScript in 24 Hours

Sams Teach Yourself JavaScript in 24 Hours

By Michael Moncur

Quiz

Test your knowledge of event handlers in JavaScript by answering the following questions.

Questions

1:

Which of the following is the correct event handler to detect a mouse click on a link?

  1. onMouseUp
  2. onLink
  3. onClick
A1:

c. The event handler for a mouse click is onClick.

2:

When does the onLoad event handler for the <body> tag execute?

  1. When an image is finished loading.
  2. When the entire page is finished loading.
  3. When the user attempts to load another page.
A2:

b. The <body> tag's onLoad handler executes when the page and all its images are finished loading.

3:

Which of the following event object properties indicates which key was pressed for an onKeyPress event in Internet Explorer?

  1. event.which
  2. event.keyCode
  3. event.onKeyPress
A3:

b. In Internet Explorer, the event.keyCode property stores the character code for each keypress.

Share ThisShare This

Informit Network