Handling Events II 27th April 2011. Introduction Event Model Events Event Handling Navigation Events On-the-Fly Web Pages Web-Page Context Nesting On-the-Fly.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

Essentials for Design JavaScript Level One Michael Brooks
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Script Session1 INTRODUCTION.
The Web Warrior Guide to Web Design Technologies
1 Topic 6 Processing Form Input. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction Form.
JavaScript: Introduction to Handling Events 20 th April 2011.
Cascading Style Sheets 23 rd March. Cascading Style Sheets (CSS) CSS Syntax Linking CSS to XHTML Inheritance & Cascading Order Font Properties Text Properties.
Cascading Style Sheets 26 th March. Introduction 1. CSS types 2. Pseudoclasses and pseudoelements 3. Other considerations 4. Worked example.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.
Lecture 13. A Very Brief Introduction to HTML and XHTML, part II Instructor: Jie Yang Department of Computer Science University of Massachusetts Lowell.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
5 th February Introduction Web Development Course.
Inline, Internal, and External FIle
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
CO1552 Web Application Development HTML Forms. Websites can be made more interactive by providing facilities for users to provide data To get user entered.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript Part 1.
Introduction to JavaScript + More on Interactive Forms.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
JSP Java Server Pages Softsmith Infotech.
1 Goals and Objectives Goals Goals Understand how JavaScript makes it possible to interact with web pages, minimizes client/server traffic, enables verification.
Images & Image Maps 16 th February. Images & Image Maps Web authors can add icons, logos and high impact images to their pages Images enhance web pages.
Forms. Forms Forms are used for e-commerce, online purchases, surveys, registrations, etc. Website using forms usually collect information and must use.
ASP.NET Controls. Slide 2 Lecture Overview Identify the types of controls supported by ASP.NET and the differences between them.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
JavaScript, Part 3 Instructor: Charles Moen CSCI/CINF 4230.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Tables 23 rd February. What XHTML have we done so far? Hyperlinks & anchors - XHTML supports 3 types of lists:  Ordered – +  Unordered – +  Definition.
Frames 2 nd March. Write the code for this using tables and using layers …..
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Event Handling & AJAX IT210 Web Systems. Question How do we enable users to dynamically interact with a website? Answer: Use mouse and keyboard to trigger.
USING JAVASCRIPT TO SHOW AN ALERT Web Design Sec 6-2 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
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 and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
JavaScript, Third Edition 1 SELECTION LIST Demo. JavaScript, Third Edition 2 Description This web page will edit the slection to ensure an option was.
G046 – Lecture 2A Recognising Web-Technologies Mr C Johnston ICT Teacher
XHTML Forms.
Using JavaScript to Show an Alert
Web Development & Design Foundations with HTML5
Frames 8th March.
Web Development & Design Foundations with HTML5 7th Edition
AJAX.
Introduction to Programming and JavaScript
JavaScript and Ajax (JavaScript Events)
Web Programming and Design
Presentation transcript:

Handling Events II 27th April 2011

Introduction Event Model Events Event Handling Navigation Events On-the-Fly Web Pages Web-Page Context Nesting On-the-Fly Web Pages Disabling XHTML actions Last week’s lecture

Introduction What is an event? Give an example. What is an event handler? Give an example. Why are events needed in an XHTML web page? When do we use events most? What can event handlers be written as? Where are they written? What predefined functions have you come across in JavaScript?

Event Model Reminder Events can be classified into two broad groups:  Navigation: clicking on links to browse through web pages  Filling a form: entering data and checking form elements Event handler is included as an attribute of a XHMTL tag  Event handlers can be written as:  Inline script: JavaScript code is included inside XHTML tag  Function call: event handlers are written as functions in tag and called from the XHTML tag

Event Model

Navigation Elements Navigation group of actions  Click a hyperlink  Open a new URL  Quit the browser Clicking an hyperlink generates the following events:  click -> when the link is clicked  mouseOver -> when the mouse is moved over the link  mouseOut -> when mouse is moved away from the link Loading and unloading web pages are also separate events Appropriate event handling grabs attention of the surfer because it makes the page dynamic

Navigation Elements click event of

Navigation Elements: Code click event of Divisible By Number //define event handler function sale() { str = "We have a 30% off sale today on these items" + "\n"; str += "All shirts and shorts in store" + "\n"; str += "Garden supplies" + "\n"; str += "Swimming pool supplies" + "\n"; str += "Outdoor camping equipment" + "\n"; str += "Beach supplies" + "\n"; alert (str); } //sale() Get 30% off any purchase today inline Function call

Web Pages On-the-Fly Web pages can be created in 2 ways:  Using the server  Using the client Using the server is not recommended as it increases server traffic Using the client utilises the concept of creating web pages on-the-fly This concept uses two web pages and the second web page is rendered based on the decision taken for event from the first web page Web pages on-the the-fly can be used as part of any event handler

Web Pages On-the-Fly Create a web page on- the-fly using JavaScript program

Web Pages On-the-Fly Create a web page on-the-fly using JavaScript program Two Web Pages in One //create a Web page on-the-fly function newCooking() { page = " "; page += " "; page += " Web page on-the-fly "; page += " "; page += " We hope you like our Pizza. We spent a year developing the recipe. "; page += " "; document.write (page); } //newCooking() Try our new Pizza This Web page uses a Web page on-the-fly. When you click the above link, the other page displays. Click the browser Back button to come back to this page Page 1 Page 2

Web Pages Context A web browser can have only one active web page at a time Any code or handlers that the browser needs must be included in the code of active web page The browsers use web page context to respond to interactions

Web Pages Context

<html><head> Webpage Context Webpage Context //create a Web page on-the-fly function newCooking() { page = " "; page += " "; page += " Web page on-the-fly "; page += " "; page += "function newChef(name){"; page += "alert('Our new Chef ' + name + ' invented the recipe')"; page += "} //newChef()"; //must escape "/" by using "\" page += " "; page += " We hope you like our Pizza. page += " We hope you like our Pizza. We spent a year developing the recipe. "; page += " "; document.write (page); } //newCooking() </script></head><body> Try our new Pizza Try our new Pizza </body></html>

Nested Web Pages on-the-fly We can embed a web page on-the-fly inside a parent web page for any number of levels to create nested web pages We usually do not require more than 2 levels of nesting

Nested Web Pages on-the-fly Two-level nesting of web pages

Nested Web Pages on-the-fly function firstPage(){ …… page += "function secondPage(){"; …… page += "} //secondPage()"; …… page += " "; page += " This is the first Web page on-the-fly "; page += " "; page += "Open the Second Web page on-the-fly "; page += " "; document.write(page); document.close(); } //firstPage() ….. Open the first Web page on-the-fly

Disabling Actions Some XHTML elements have actions associated with them Without JavaScript, these actions are executed upon clicking This execution can be made conditional by using event handler functions If the condition is true execution takes place or else it is stopped

Disabling Actions

function checkIt(balance){ function checkIt(balance){ if (balance >= 0){ alert("Thank you!\nProceed to register."); return true; } //if else { alert("Sorry! You owe money.\nYou cannot register."); return false; } //else } //checkIt() </script>…….<body> Check if you can register for courses Check if you can register for courses Positive balance Positive balance Negative balance Negative balance </body>

Reference Steven M. Schafer (2005), HTML, CSS, JavaScript, Perl, and PHP Programmer's Reference, Hungry Minds Inc,U.S. Dan Cederholm (2005), Bulletproof Web Design: Improving Flexibility and Protecting Against Worst-Case Scenarios with XHTML and CSS, New Riders. Ibrahim Zeid (2004), Mastering the Internet, XHTML, and Javascript