JavaScript and Events CS Programming Languages for Web Applications

Slides:



Advertisements
Similar presentations
The jQuery library. What is jQuery ? A javascript lightweight library Is very easy to use Is powerful Is cross-browser compatible Downloadable from jQuery.com,
Advertisements

Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
Event Handling. Overview How to listen (and not listen) for events Creating a utility library (and why you should) Typology of events Pairing event listeners.
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.
JavaScript Client Side scripting. Client-side Scripts Client-side scripts, which run on the user’s workstation can be used to: Validate user inputs entered.
CP476 Internet Computing JavaScript and HTML1 1.JavaScript Execution Environment The JavaScript Window object represents the window in which the browser.
JavaScript and The Document Object Model MMIS 656 Web Design Technologies Acknowledgements: 1.Notes from David Shrader, NSU GSCIS 2.Some material adapted.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Execution Environment for JavaScript " Java Script Window object represents the window in which the browser displays documents. " The Window object provides.
Chapter 5 JavaScript and HTML Documents. © 2006 Pearson Addison-Wesley. All rights reserved JavaScript Execution Environment - The JavaScript.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 JavaScript and HTML Documents.
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.
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.
DOM Events. JS Events Outline About Events – Introduction – Registering events – Getting information from events Event order/phases – Preventing default.
JavaScript - A Web Script Language Fred Durao
Chapter 5 © 2005 by Addison Wesley Longman, Inc JavaScript Execution Environment - The JavaScript Window object represents the window in which the.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
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.
Thursday, August 6 th, 2015 Instructor: Craig Duckett Event Handling.
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.
Dr. Ahmet Cengizhan Dirican BIL 374 Internet Technologies 5. JavaScript and HTML Documents.
H.Melikyan/4910/031 Programming the World Wide Web JavaScript Dr.Hayk Melikyan Departmen of Mathematics and CS JavaScript and HTML Documents.
Host Objects: Browsers and the DOM
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
Events Event Handling in JavaScript SoftUni Team Technical Trainers Software University
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
Modern JavaScript Develop And Design Instructor’s Notes Chapter 8 – Event Handling Modern JavaScript Design And Develop Copyright © 2012 by Larry Ullman.
 objects in Client  What is Event?  Event Handlers  programming.
CHAPTER 7 JQUERY WHAT IS JQUERY? jQuery is a script. It is written in JavaScript.
Implement User Input Windows Development Fundamentals LESSON 2.4A.
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.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 5 Host Objects: Browsers.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Methods and Object Information. Some Document Methods.
XHTML Forms.
JQuery.
JavaScript and HTML Simple Event Handling 11-May-18.
Introduction to JavaScript Events
CGS 3066: Web Programming and Design Spring 2017
Section 17.1 Section 17.2 Add an audio file using HTML
JAVASCRIPTS AND HTML DOCUMENTS
JavaScript and HTML Simple Event Handling 19-Sep-18.
CSE 154 Lecture 11: More Events.
JavaScript and HTML Documents
CHAPTER 7 JavaScripts & HTML Documents
Events.
© 2015, Mike Murach & Associates, Inc.
Introduction to jQuery
JavaScript and Events CS Programming Languages for Web Applications
CSE 337 Lecture 10: Events.
CS7026 jQuery Events.
Lecture 11: Keyboard Events
CHAPTER 6 EVENTS. CHAPTER 6 EVENTS WHAT IS AN EVENT?
JavaScript and HTML Simple Event Handling 26-Aug-19.
JavaScript: BOM and DOM CS Programming Languages for Web Applications
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

JavaScript and Events CS 4640 Programming Languages for Web Applications [Robert W. Sebesta, “Programming the World Wide Web Jon Duckett, Interactive Frontend Web Development]

Interactions create event Events Interactions create event Events trigger code Code responds to users Scripts often respond to events by updating the content of the page (via DOM) which makes the page appear interactive

(Some) Event Types UI events – occur when a user interacts with the browser’s user interface (UI) – work with window object UI Events Description load Web page has (just) finished loading unload Web page is unloading error Browser encounters a JavaScript error or unavailable web resources resize Browser window has been resized scroll User has scrolled up or down the page

(Some) Event Types Focus events – occur when an element gains or loses focus Focus Events Description focus / focusin Element gains focus blur / focusout Focus loses focus Keyboard events – occur when a user interacts with the keyboard Keyboard Events Description keydown User first presses a key keyup User releases a key keypress Character is being inserted

(Some) Event Types Mouse events – occur when a user interacts with a mouse, trackpad, or touchscreen Mouse Events Description click User presses and releases a button over the same element dbclick User presses and releases a button twice over the same element mousedown User presses a mouse button while over an element mouseup User releases a mouse button while over an element mousemove User moves a mouse (not on a touchscreen) mouseover User moves a mouse over an element (not on a touchscreen) mouseout User moves a mouse off an element (not on a touchscreen)

(Some) Event Types Form events – occur when a user interacts with a form element Form Events Description input Value in any <input> or <textarea> element has changed or any element with t he contenteditable attribute change Value in select box, checkbox, or radio button changes submit User submits a form (using a button or a key) reset User clicks on a form’s reset button cut User cuts content from a form field paste User pastes content into a form field select Users selects some text in a form field

(Some) Event Types Mutation events – occur when the DOM structure has been changed by a script Mutation Events Description DOMSubtreeModified Change has been made to a document DOMNodeInserted Node has been inserted as a direct child of another node DOMNodeRemoved Node has been removed from another node

How Events Trigger Code Select the element node the script will respond to Indicate which event on the selected node will trigger the response (bind an event to a DOM node) “Event handling” Specify the code to run when the event occurs

Example: Event Handling (Lazy) http://www.cs.virginia.edu/~up3f/cs4640/examples/js/event-enhancement/bind-event-lazy.html bind-event-lazy.html

Example: Event Handling (Tradition) http://www.cs.virginia.edu/~up3f/cs4640/examples/js/event-enhancement/bind-event-tradition.html bind-event-tradition.html

Example: Event Handling (Modern) http://www.cs.virginia.edu/~up3f/cs4640/examples/js/event-enhancement/bind-event-modern.html bind-event-modern.html

Example: Using Parameters with Event Listener http://www.cs.virginia.edu/~up3f/cs4640/examples/js/event-enhancement/bind-event-with-param.html bind-event-with-param.html

Example: Supporting Older Version of IE (w/o Param) http://www.cs.virginia.edu/~up3f/cs4640/examples/js/event-enhancement/bind-event-support-multiple-browsers.html bind-event-support-multiple-browsers.html

Example: Supporting Older Version of IE (w/ Param) http://www.cs.virginia.edu/~up3f/cs4640/examples/js/event-enhancement/bind-event-with-param.html bind-event-with-param.html

Summary Events occur when user interacts with a web browser or a web page (screen). Binding specifies the event that can happen and on which element the event happens. When an event occurs on an element, it can trigger a JavaScript function. The function then manipulates the page to response to the user.