Chapter 14: DHTML: Event Model

Slides:



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

JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
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.
Page 1 of 39 Javascript Chapters 13, 14 Vadim Parizher Computer Science Department California State University, Northridge Fall 2003 Slides from text Book.
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.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
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.
JavaScript Part 1.
1 JavaScript: Event Model November 1, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel, and Goldberg.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
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.
 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.
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.
Chapter 7: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
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.
1 JavaScript 2 JavaScript. 2 Rollovers Most web page developers first use JavaScript for rollovers A rollover is a change in the appearance of an element.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
Chapter 14: Dynamic HTML: Event Model Presented by: Colbie Brown CS340 Java Web Development Dr. Gloria Carter Love.
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.
CSS1 Dynamic HTML Objects, Collections & Events. CSS2 Introduction Dynamic HTML treats HTML elements as objects. Element’s parameters can be treated as.
Introduction to DHTML. What is DHTML? Dynamic HTML Just as Access is Dynamic Database environment Can have controls that respond to events Can have centralized.
 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.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
5 th and 4 th ed: some from chapters 9, 12, 13 SY306 Web and Databases for Cyber Operations Slide Set #8: Dynamic HTML.
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
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.
Jozef Goetz contribution, © by Pearson Education, Inc. All Rights Reserved.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
CIS 375—Web App Dev II DHTML. 2 Introduction to DHTML _________ HTML is “a term used by some vendors to describe the combination of HTML, style sheets.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Methods and Object Information. Some Document Methods.
5.1 JavaScript Execution Environment
JavaScript and HTML Simple Event Handling 11-May-18.
Web Development & Design Foundations with HTML5
Introduction to JavaScript Events
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
Chapter 14 - Dynamic HTML: Event Model
JavaScript Events.
13 JavaScript: Events.
Events Comp 205 Fall 2017.
CHAPTER 7 JavaScripts & HTML Documents
COP 3813 Intro to Internet Computing
Chapter 14 - Dynamic HTML: Event Model
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: DHTML: Event Model CIS 275—Web Application Development for Business I

Event onclick When the user clicks an item with the mouse, the onclick event ______. Using the _____ property of the script element: <script type = "text/javascript" for = "para" event = "onclick"> alert( "Hi there" ); </script> <p id = "para">Click on this text!</p> _______ scripting: <input type = "button" value = "Click Me!" onclick = "alert( 'Hi again' )" />

Event onload The onload event fires when an element finishes loading successfully, including its _________. <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Event onload</title> <script type = "text/javascript"> var seconds = 0; function startTimer() { window.setInterval( "updateTime()", 1000 ); } function updateTime() { seconds++; soFar.innerText = seconds; } </script> </head> <body onload = "startTimer()"> <p>Seconds you have spent viewing this page so far: <strong id = "soFar"> 0 </strong></p> </body> </html>

Error Handling w/ onerror The content of web pages changes over time. Error messages presented by the browser can be confusing. Scripts can use the onerror event to execute specialized error-handling code. Such code may only work correctly if “Script debugging” is disabled in Internet Explorer. window.onerror = handleError; function doThis() { alrrt( "hi" ); // error } function handleError( errType, errURL, errLineNum ) { window.status = "Error: " + errType + " on line " + errLineNum; // Returning a value of true // cancels the browser’s reaction. return true;

Event onmousemove Event onmousemove fires repeatedly whenever the mouse moves. <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>onmousemove event</title> <script type = "text/javascript"> <!-- function updateMouseCoordinates() { coordinates.innerText = event.srcElement.tagName + " (" + event.offsetX + ", " + event.offsetY + ")"; } // --> </script> </head> <body style = "background-color: wheat" onmousemove = "updateMouseCoordinates()"> <span id = "coordinates"> (0, 0)</span><br /> <img src = "deitel.gif" style = "position: absolute; top: 100; left: 100" alt = "Deitel" /> </body> </html>

Rollovers w/ onmouseover and onmouseout When a mouse cursor moves over an element, the onmouseover event fires. When a mouse cursor leaves an element, the onmouseout event fires. Creating _______ objects for rollovers: captionImage1 = new Image(); captionImage1.src = "caption1.gif"; captionImage2 = new Image(); captionImage2.src = "caption2.gif";

Logic for onmouseover/out Image object is associated with an image ______ <img> tag has a src and an ____ When any mouseover or mouseout occurs, call the appropriate function In that function, if event was for that <img> id, set the _____ for that image to the image object See p. 460 for example.

Form Processing The onfocus event fires when an element (e.g., a form field) is made active by a click or a ______. The onblur event fires when an element loses _______. onfocus and onblur can be used to call a function onfocus = aFunction(); onblur = anotherFunction(); onblur is especially helpful to _________ user input in a form field. The onsubmit and onreset events fire when the Submit or Reset buttons are clicked, respectively. onsubmit is useful for confirming submission.