WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs 2003-04 WDMD.

Slides:



Advertisements
Similar presentations
Chapter 08: Adding Adding Interactivity Interactivity With With Behaviors Behaviors By Bill Bennett Associate Professor MSJC CIS MVC.
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
The Web Warrior Guide to Web Design Technologies
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Using Data Types (No Audio Component) © Dr. David C. Gibbs
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
Javascript Document Object Model. How to use JavaScript  JavaScript can be embedded into your html pages in a couple of ways  in elements in both and.
20-Jun-15 JavaScript and HTML Simple Event Handling.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
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.
Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Working with Forms in JavaScript (NON-audio version) © Dr. David C. Gibbs
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
CST JavaScript Validating Form Data with JavaScript.
Web Programming Material From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web 1 Introduction The JavaScript Programming.
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
CP476 Internet Computing JavaScript and HTML1 1.JavaScript Execution Environment The JavaScript Window object represents the window in which the browser.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript Part 1.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
Hyperlinks. Linking pages…Hyperlinks 2 Lecture 8  Hyperlink “A clickable HTML element that will direct the web browser to display a different Web page.
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
Images (1) Three most popular formats – Graphics Interchange Format (GIF) – Joint Photographic Experts Group (JPEG) – Portable Network Graphics (PNG) –
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 WDMD 170 – UW Stevens Point WDMD 170 Internet Languages eLesson: CSS Introduction to Style Sheets (NON-audio version) © Dr. David C. Gibbs
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
JavaScript Tutorial 1 - Introduction to JavaScript WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Introduction to JavaScript (NON.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Decision Making with Control Structures and Statements (non-audio version) © Dr. David.
JavaScript - A Web Script Language Fred Durao
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (there is an audio component to this eLesson) © Dr.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: HTML/XHTML Tables (NON-audio version) © Dr. David C. Gibbs
JavaScript Tutorial 1 - Introduction to JavaScript WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Introduction to JavaScript – A First.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
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.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Introduction to JavaScript Objects, Properties, Methods.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Working with Windows (No audio component) © Dr. David C. Gibbs
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.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
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.
Web Development & Design Foundations with HTML5
Web Development & Design Foundations with HTML5 7th Edition
JAVASCRIPTS AND HTML DOCUMENTS
Events Comp 205 Fall 2017.
Introduction to Programming and JavaScript
JavaScript and Ajax (JavaScript Events)
Web Programming and Design
Web Programming and Design
Presentation transcript:

WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD 170 – UW Stevens Point

2 Tutorial 2 Variables, Functions, and Events Section B – Using Events

WDMD 170 – UW Stevens Point 3 Tutorial 2B Topics Section B – Using Events –About events –About HTML tags and events –How to use event handlers –About links –How to use link events –How to create an image map

WDMD 170 – UW Stevens Point 4 Events Understanding Events –Events are actions that occur usually as a result of something the user does. –Quick examples: clicking a button is an event changing a text field moving the mouse over a hyperlink. –Event handlers, such as onChange and onClick, to make your script react to events. specific JavaScript code in response to a given situation

WDMD 170 – UW Stevens Point 5 Understanding Events Events –Two basic types User-generated events –e.g., mouse-click System-generated events –e.g., load event  triggered by web browser when HTML document finishes loading –e.g., unload event  when the document is unloaded from the browser

WDMD 170 – UW Stevens Point 6

7 Input Events In a given web page, there are a LOT of events going on! Check out this example of input events.example of input events As a programmer, you need to learn how to handle the events associated with your task.

WDMD 170 – UW Stevens Point 8 HTML Tags and Events HTML elements allow user to trigger events – tag Creates input fields that interact with users Syntax: Type attribute determines the type of input field – creates a text field Name attribute assigns a unique name to the element that JavaScript can use to reference it

WDMD 170 – UW Stevens Point 9 tag Used to gather information on a web form. Must be embedded between … tags Here is a more complete example: <input type= " text " many types possible value= " default text " the initial value name= " txtInput " a unique name onBlur= " alert(this.value); " /> an event handler NOTE: this should all be on one line! (Separately displayed here for clarity.)

WDMD 170 – UW Stevens Point 10 eTask 1: Copy this code into the body section of an HTML document. Save this file as “inputTypeText.htm”. (NOTE: the input tag should all be on one line) Click inside the text box; type something in – like “JavaScript RULES!”. Click outside the text box. Anywhere will do – you are trying to trigger the Blur event.

WDMD 170 – UW Stevens Point 11

WDMD 170 – UW Stevens Point 12

WDMD 170 – UW Stevens Point 13 Event Handlers Code that executes in response to a specific event SYNTAX: – Event handler naming convention –Event name with a prefix of “on” –e.g., onClick –

WDMD 170 – UW Stevens Point 14 eTask 2: Copy this code into the body section of an HTML document. (NOTE: the input tag should all be on one line) Save this file as “inputTypeButton.htm”. View the page. Click the button. What is the event? What is the name of the “event handler?”

WDMD 170 – UW Stevens Point 15 List of Events and Event Handlers Events are things like click, focus, blur, change, mouseout, mouseover, load, unload… Event handlers are named “onEvent”, such as onClick, onFocus, onBlur, onChange, etc. The JavaScript Guide (jshtm.zip file) has a nice summary of events and their corresponding event handlers.jshtm.zip summary of events

WDMD 170 – UW Stevens Point 16 Wait a minute! Q: What’s this “alert” thing? A: a JavaScript method (function) that displays a dialog box with a message and an OK button. Let’s practice reading a “reference” guide. Here’s the JSHTM spiel on alert.JSHTM spiel on alert Read their description and use the back-button to return.

WDMD 170 – UW Stevens Point 17 Wait another minute! Q: What’s this “prompt” thing? A: This time let’s go straight to the guide for a description of prompt. description of prompt Once again, read their description and use the back- button to return.

WDMD 170 – UW Stevens Point 18 And… as long as we’re in the mode of looking up JS methods… Q: How about “confirm”?confirm Once again, read their description and use the back-button to return. Each of these methods will be used in future programming.

WDMD 170 – UW Stevens Point 19 Methods (or functions): alert, prompt, confirm REVIEW: There are two types of functions: those that do something; those that return something. Does alert() return anything? Does prompt() return anything? Does confirm() return anything? ANSWERS: No, yes, yes. Notice how that difference plays out in the next eTask.

WDMD 170 – UW Stevens Point 20 eTask 3 Refer to the instructions on pages 86-8 (Gosselin). Create the file GreetVisitor.htm and save it in your Tutorial02 folder. Preview the.htm file. In step 16, simply click on the browser’s Home Page icon to force the unload event to occur.

WDMD 170 – UW Stevens Point 21 Link tags Links –Used to open files or navigate to other documents on the web –Text or image used to represent a link in an HTML document is called an anchor –Use anchor tag to process a URL

WDMD 170 – UW Stevens Point 22 Review of link tags Links –Two types of URL Absolute –Refers to the specific location of the document » »C:\webpages\homepage.html Relative –Refers to location of document according to the location of currently loaded document »/subdirectory/otherpage.html »Increases portability of web site

WDMD 170 – UW Stevens Point 23 Using Link Events Links Events –Primary event is the click event For default operation, no event handler is required –Overriding the default click event Add onClick event handler that executes custom code Event handler must return true or false Can use built-in confirm() method to generate Boolean value

WDMD 170 – UW Stevens Point 24

WDMD 170 – UW Stevens Point 25 Other Events associated with Links MouseOver event –Occurs when the mouse moves over a link MouseOut event –Occurs when the mouse moves off a link Can be used to change the text that appears in the browser’s status bar –Use JavaScript status property

WDMD 170 – UW Stevens Point 26 onClick, onMouseOver, onMouseOut events <A HREF = "GreenPage.html" onClick = "return confirmPageChange();" onMouseOver = "status ='This link opens the green page'; return true;" onMouseOut = "status ='You did not open the green page!!'; return false;"> Click here to open the green page

WDMD 170 – UW Stevens Point 27 eTask 4 Refer to the instructions on pages 93-4 (Gosselin). Create the files RedPage.htm and GreenPage.htm as described. Open either one.

WDMD 170 – UW Stevens Point 28 Using Events in an Image Map Creating an Image Map –An image divided into regions Each region associated with URL via the tag Use,, and tags to create an image map Areas are divided using pixel coordinates of image –Picture elements

WDMD 170 – UW Stevens Point 29

WDMD 170 – UW Stevens Point 30 Type of Image Maps Two basic types –Client-side Part of an HTML document –Server-side Code resides on a web server

WDMD 170 – UW Stevens Point 31 Creating an Image Map in an HTML Document 1. Place image in document using tag –Use usemap attribute to reference image map by name 2. Define image map using tag –Use name attribute to give map a name

WDMD 170 – UW Stevens Point 32 Creating an Image Map in an HTML Document (2) 3. Define image map regions using tag –Use shape attribute to specify shape of region rect, circle, poly <area href=“baseball.html” shape=“rect” coords=“0,0,150,125” onMouseOver=“status=‘Baseball Web Page’;return true;” onMouseOut=“status=‘’;return true;”>

WDMD 170 – UW Stevens Point 33

WDMD 170 – UW Stevens Point 34

WDMD 170 – UW Stevens Point 35 eTask 5 Refer to the instructions on pages (Gosselin). Create and save the image map file ShowCountry.htm This one is tough! You’ll probably develop a question to post in your eReview discussion group.

WDMD 170 – UW Stevens Point 36 Assignment Exercise #1 page 105 (Gosselin, Tutorial 02B) Complete the exercise and attach the file in a post to your eReview discussion group. Describe any difficulties you might have had in completing the problem. Please do not copy it to your web page until one week later.

WDMD 170 – UW Stevens Point 37 Assignment Exercise #5 page 106 (Gosselin, Tutorial 02B) Complete the exercise and attach the file in a post to your eReview discussion group. Describe any difficulties you might have had in completing the problem. Please do not copy it to your web page until one week later.

WDMD 170 – UW Stevens Point 38 End of eLesson Jump to the Beginning of this eLesson WDMD 170 Course Schedule D2L Courseware Site