Chapter 14: Dynamic HTML: Event Model Presented by: Colbie Brown CS340 Java Web Development Dr. Gloria Carter Love.

Slides:



Advertisements
Similar presentations
Session 11 Dynamic HTML: Event Model and Filters Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
Advertisements

The Web Warrior Guide to Web Design Technologies
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
20-Jun-15 JavaScript and HTML Simple Event Handling.
Computer Science 103 Chapter 4 Advanced JavaScript.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Lesson 2 Event Handling. Object Event Handlers Most of the objects that make up the Document Object Model respond to asynchronous, user generated events.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Events.
CST JavaScript Validating Form Data with JavaScript.
CP476 Internet Computing JavaScript and HTML1 1.JavaScript Execution Environment The JavaScript Window object represents the window in which the browser.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
JavaScript - a Brief Introduction Anupriya. What is JavaScript Object based (not object oriented) programming language –very limited object creation –a.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Chapter 19: Adding JavaScript
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
1 JavaScript: Event Model November 1, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel, and Goldberg.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
1 Dynamic HTML III: Event Model Introduction Event model –Scripts respond to user actions and change page accordingly Moving mouse Scrolling screen.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 16 – Dynamic HTML: Event Model Outline 16.1Introduction 16.2Event ONCLICK 16.3Event ONLOAD.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 14 - Dynamic HTML: Event Model Outline 14.1 Introduction 14.2 Event onclick 14.3 Event onload 14.4.
Pemrograman Teknologi Internet W06: Functions and Events.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 14 - Dynamic HTML: Event Model Outline 14.1 Introduction 14.2 Event onclick 14.3 Event onload.
JavaScript - A Web Script Language Fred Durao
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content.
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
Thursday, August 6 th, 2015 Instructor: Craig Duckett Event Handling.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 16 – Dynamic HTML: Event Model Outline 16.1Introduction 16.2Event ONCLICK 16.3Event ONLOAD.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 14 - Dynamic HTML: Event Model Outline 14.1 Introduction 14.2 Event onclick 14.3 Event onload 14.4.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 4 Dynamic HTML & CSS.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
Project 8: Reacting to Events Essentials for Design JavaScript Level One Michael Brooks.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
Understanding JavaScript and Coding Essentials Lesson 8.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
JavaScript Events.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 14 - Dynamic HTML: Event Model Outline 14.1 Introduction 14.2 Event onclick 14.3 Event onload.
20-753: Fundamentals of Web Programming 1 Lecture 13: Javascript II Fundamentals of Web Programming Lecture 13: Javascript II.
Jozef Goetz contribution, © by Pearson Education, Inc. All Rights Reserved.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Internet & World Wide Web How to Program, 5/e.  JavaScript events  allow scripts to respond to user interactions and modify the page accordingly  Events.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
JavaScript and HTML Simple Event Handling 11-May-18.
Introduction to JavaScript Events
Chapter 14: DHTML: Event Model
Web Development & Design Foundations with HTML5 7th Edition
JAVASCRIPTS AND HTML DOCUMENTS
JavaScript and HTML Simple Event Handling 19-Sep-18.
Chapter 14 - Dynamic HTML: Event Model
JavaScript Events.
13 JavaScript: Events.
CHAPTER 7 JavaScripts & HTML Documents
Web Design and Development
JavaScript and Ajax (JavaScript Events)
JavaScript and HTML Simple Event Handling 26-Aug-19.
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

Chapter 14: Dynamic HTML: Event Model Presented by: Colbie Brown CS340 Java Web Development Dr. Gloria Carter Love

TABLE OF SLIDES oINTRODUCTION oEVENTONCLICK oEVENTONLOAD oERROR HANDLING WITH ONERROR oTRACKING THE MOUSE WITH EVENT ONMOUSEMOVE oROLLOVERS WITH ONMOUSEOVER AND ONMOUSEOUT oFORM PROCESSING WITH ONFOCUS AND ONBLUR oMORE FORM PROCESSING WITH ONSUBMIT AND ONRESET oSUMMARY oREFERENCES

INTRODUCTION We have seen that XHTML pages can be controlled via scripting. Dynamic HTML with the event model exists so that scripts can respond to user interactions and change the page accordingly. This makes Web applications more responsive and user friendly and can reduce server load.

INTRODUCTION With the even model, scripts can respond to a user who is moving the mouse, scrolling up or down the screen or entering keystrokes. Content becomes more dynamic, while interfaces become more intuitive. In this chapter, we will discuss how to use the event model to respond to user actions. Examples are given of event handling and useful events, which range from mouse capture to error handling to form processing.

EVENTONCLICK One of the most common events is onclick. When the user clicks a specific item with the mouse, the onclick event fires. With JavaScript, we are able to respond to onclick and other events. Below is an example of simple event handling for the onclick event. Figure 14.1

EVENTONLOAD The onload event fires whenever an element finishes loading successfully. Frequently, this event is used in the body element to initiate a script after the page loads into the client. Below is an example that uses the onload event for this purpose. The script called by the onload event updates a timer that indicates how many seconds have passed since the document was loaded. Figure 14.2

ERROR HANDLING WITH ONERROR Sometimes a script refers to objects that existed at a specified location when the script was written, but the location changes at a later time, rendering the script invalid. The error dialog presented by the browser in such a case can be confusing to the user. To prevent this dialog box from displaying and to handle errors more elegantly, scripts can use the onerror event to execute specialized error- handling code. Figure 14.3 gives an example. Figure 14.3

TRACKING THE MOUSE WITH EVENT ONMOUSEMOVE Event onmousemove fires repeatedly whenever the user moves the mouse over the Web page. The link below shows an example that uses this event to update a coordinate display that gives the position of the mouse in the coordinate system of the object containing the mouse cursor. Figure 14.4

ROLLOVERS WITH ONMOUSEOVER AND ONMOUSEOUT Two more events fired by mouse movements are onmouseover and onmouseout. When the mouse cursor moves over an element, an onmouseover event occurs for that element. When the mouse cursor leaves the element, an onmouseout event occurs for that element. The link below uses these events to achieve a rollover effect that updates text when the mouse cursor moves over it. Thus, a technique for creating rollover images is also introduced. Figure 14.6

FORM PROCESSING WITH ONFOCUS AND ONBLUR The onfocus and onblur events are particularly useful when dealing with form elements that allow user input. The onfocus event fires when an element gains focus and onblur fires when an element loses focus, which occurs when another control gains the focus. Figure 14.7

MORE FORM PROCESSING WITH ONSUBMIT AND ONRESET Two more useful events for processing forms are onsubmit and onreset. These events fire when a form is submitted or reset. The function formSubmit executes in response to the user submitting the form. Figure 14.8

SUMMARY oThe event model allows scripts to respond to user actions and change a page accordingly. oThis makes Web applications responsive and user friendly and can greatly lessen server load but can cause compatibility problems. oWith the event model, scripts can respond to a user moving the mouse, scrolling up or down the screen or entering keystrokes. Content becomes more dynamic, and interfaces become more intuitive. oOne of the most common events is onclick. When the user clicks the mouse, onclick fires. oEvent onmousemove fires constantly whenever the mouse is in motion. oThe event object contains information about the triggered event.

REFERENCES Internet & World Wide Web: How To Program 3 rd Ed. Companion Website: ANY QUESTIONS???