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.

Slides:



Advertisements
Similar presentations
function coffeeinfo() { document.getElementById('p3').innerHTML = "The word 'coffee' was.
Advertisements

JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
Session 11 Dynamic HTML: Event Model and Filters Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
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.
Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
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.,
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 Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
JavaScript Part 1.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Intro to JavaScript. Use the tag to tell the browser you are writing JavaScript.
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.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
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,
JavaScript - A Web Script Language Fred Durao
Intro to JavaScript Scripting language –ECMAScript compliant –Client side vs. server side Syntactic rules –White space –Statement end: ; optional –Comments:
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
Intro to JavaScript. Some simple examples Examples from our webpage Examples from Andrews webpage Today’s Example.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
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.
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
Thursday, August 6 th, 2015 Instructor: Craig Duckett Event Handling.
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming control structures, events, objects.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
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.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Web Programming Java Script & jQuery Web Programming.
HTML FORMS The TEXT Object Presented By: Ankit Gupta.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
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.
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.
Event Handlers Events are asynchronous. When an event occurs, JavaScript can execute code in response to the user’s action. This response to the user-initiated.
Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.
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.
CSC 121 Computers and Scientific Thinking Fall Event-Driven Programming.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
JAVASCRIPT A quick review. True False ■The DOM is a standardized way of referring to parts of a Web page. ■TRUE ■In the DOM, attributes have their own.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Functions Wouldn’t it be nice to be able to bring up a new animal and paragraph without having to reload the page each time? We can! We can place the.
WEB SYSTEMS & TECHNOLOGY. Java Script  JavaScript created by Netscape  It is also client side programming  It can be use for client side checks.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
JavaScript and HTML Simple Event Handling 11-May-18.
Web Development & Design Foundations with HTML5
JavaScript (JS) Basics
Web Development & Design Foundations with HTML5 7th Edition
JavaScript and HTML Simple Event Handling 19-Sep-18.
JavaScript Defined General Syntax Body vs. Head Variables Math & Logic
JavaScript and Ajax (JavaScript Events)
Barb Ericson Georgia Institute of Technology May 2006
Web Programming and Design
JavaScript and HTML Simple Event Handling 26-Aug-19.
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

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 of the page when the cursor is placed over it. Rollovers have come to mean that something is a link A rollover replaces one image with another

3 Rollovers Most web page developers first use JavaScript for rollovers A rollover is a change in the appearance of an element of the page when the cursor is placed over it. Rollovers have come to mean that something is a link A rollover replaces one image with another

4 The Images Generating the images for a rollover can be complex It can be difficult to ensure that the slices of an image fit together correctly when assembled in a table Photoshop’s Slice tool can be useful

5 onMouseOver = The mouseOver event is triggered when the cursor hovers over the item It can be used for rollovers

6 onMouseOver = Var happyFace = new Image(); happyFace.src = “happy.gif” <img src=“face.gif” id=“face” onMouseOver = ”document.face.src = happyFace.src”>

7 onMouseOver = Var happyFace = new Image(); happyFace.src = “happy.gif” <img src=“face.gif” id=“face” onMouseOver = ”document.face.src = happyFace.src”> Creates new image object called happyFace Sets source of happyFace to the gif The image tag is given the name “face” When the cursor hovers over the image the source property of the image named face is chanced to the source of the image object happy References image by id In the header

8 onMouseOut The built-in event onMouseOut is triggered when the cursor moves off an object. Usually a rollover has a mouse over and mouse out part to restore the original image

9 var good = new Image(); good.src ="colin-good.jpg"; var evil = new Image(); evil.src ="colin-evil.jpg"; onmouseover & onmouseout

10 More built-in events onload onunload onfocus onblur onchange onsubmit onkeydown onkeypress Often used when working with cookies Can be used to trigger validation of form fields as user enters the data

11 Alerts & Dialogs JavaScript can control windows to get the user’s attention or solicit input The exact look of these windows will depend on the operating system

12 Alert Box alert (“This is important!”) Alert boxes only inform the user. They does accept any input.

13 Confirm Box var name=confirm (“Your credit card will be charged") Confirm evaluates to true is OK is clicked and false otherwise

14 Prompt Box Prompt evaluates to the user’s input The second parameter is text that will appear by default name=prompt("Please enter your name","")

15 Prompt box Sample Java Script Page var name; name=prompt("Please enter your name",""); if (name!=null && name!="") { document.write("Hello " + name); } Thanks for visiting my webpage. This page prompts for the user's name in a dialog box. If the user cancels the value is null The name is included in in the greeting Because the script is in the body of the page it runs when the page is loaded

16 While Loop While (condition) Statement; var top; top = prompt("Enter a number",""); if (top!=null && name!="") { var n = 0; while (n<=top) { document.write(n); n = n + 1; } };

17 Do While Loop Do Statement; While (condition) Do While loop will always executed the statement at least once So be careful

18 For Loop For (intA=2; intA <=10; intA++) statement; A JavaScript For loop has three parts Initialize counterHalt ConditionIncrement