Page 144 - DCAP202_Fundamentals of Web Programming
P. 144
Unit 11: Handling Events Using JavaScript
9. The event object passed to the specified event handler function is a ............................ Notes
10. A ............................ event occurs when a user selects some of the text within a text or
textarea field.
11. The .............................. handler executes JavaScript code when a select event occurs.
11.3 Summary
By using JavaScript, we have the ability to create dynamic web pages.
Events are normally used in combination with functions, and the function will not be
executed before the event occurs!
The onLoad and onUnload events are triggered when the user enters or leaves the page.
The onFocus, onBlur and onChange events are often used in combination with validation
of form fields.
The onSubmit event is used to validate ALL form fields before submitting it.
When using the onclick event to trigger an action, also consider adding this same action to
the onkeydown event.
The onclick property returns the onClick event handler code on the current element.
The event object passed to the specified event handler function is a MouseEvent.
11.4 Keywords
Events: Events are normally used in combination with functions, and the function will not be
executed before the event occurs.
MouseEvent: The event object passed to the specified event handler function is a MouseEvent.
onclick: The onclick property returns the onClick event handler code on the current element.
onLoad: This 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.
onSelect: A select event occurs when a user selects some of the text within a text or textarea field.
onSubmit: This event is used to validate ALL form fields before submitting it.
11.5 Review Questions
1. What do you mean by events?
2. Why we use events in JavaScript?
3. How to use onMouseOver and onMouseOut events?
4. How to change the background color of an element?
5. How do you define onLoad and onUnload event?
6. Define onLoad calls and onUnload calls.
7. Explain onBlur Event Handler.
8. Why we use onSelect Event Handler?
LOVELY PROFESSIONAL UNIVERSITY 137