More on Events Some More Events Image Rollover Objects Select-Option List Control 1.

Slides:



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

function coffeeinfo() { document.getElementById('p3').innerHTML = "The word 'coffee' was.
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
Part 5 Introduction to CSS. CSS Display - Block and Inline Elements A block element is an element that takes up the full width available, and has a line.
CSS Menus and Rollovers. Agenda foil Separating style from content 3 pages in one file Rollovers in CSS Horizontal drop-downs Vertical drop-downs.
Principles of Web Design 5 th Edition Chapter Nine Site Navigation.
Advance CSS (Menu and Layout) Miftahul Huda. CSS Navigation MENU It's truly remarkable what can be achieved through CSS, especially with navigation menus.
Navigation Bars Level 2 Extended Certificate Unit B12 Doing Business Online.
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
20-Jun-15 JavaScript and HTML Simple Event Handling.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
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.
UNIT 6 JAVASCRIPT EVENT HANDLERS &WEB BROWSERS DETECTION.
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.
HTML Forms/Events (Instructor Lesson) The Event model HTML Forms Custom Events 1.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 03 - Spring 2011.
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
Internet Mark-up Languages CO32036 Part Lecture: Elementary JavaScript.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
JavaScript – part II. The if Statement if (condition) { block of code to be executed if the condition is true }
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
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.
Website Development with Dreamweaver
CS 174: Web Programming October 7 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Intro to JavaScript Scripting language –ECMAScript compliant –Client side vs. server side Syntactic rules –White space –Statement end: ; optional –Comments:
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
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.
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.
1 CHAPTER 03: GOING FURTHER By Tharith Sriv. This chapter covers the following topics:  Flying texts or images  Using Comment  Using tag  Using …
Week 8 – Part 2 Page Layout Basics Key Concepts 1.
Event Handling © Copyright 2014, Fred McClurg All Rights Reserved.
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.
Active X – Mouse Events. Structured Graphics Control  Included in Internet Explorer v5.0  Add to page with the OBJECT tag  Accessible via scripting.
1 Chapter 05: Creating Your Form. What is a Form? When you visit some websites you see a form. With this form, you are asked to complete, for example,
 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.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
Project 8: Reacting to Events Essentials for Design JavaScript Level One Michael Brooks.
Basic Webpage Design Mark-up html document with images.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
Web Programming Java Script & jQuery Web Programming.
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.
Chapter 6 © 2014 by Pearson Education Introduction Def: A dynamic HTML document is one whose tag attributes, tag contents, or element style properties.
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.
HTML DOM The Document Object Model is a Javascript class that defines HTML elements as objects. It supports … properties methods events Image from
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
Chapter 6 Dynamic Documents with JavaScript. © 2006 Pearson Addison-Wesley. All rights reserved Introduction Def: A dynamic HTML document is.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
JavaScript and HTML Simple Event Handling 11-May-18.
JavaScript and HTML Simple Event Handling 19-Sep-18.
JavaScript Events.
Web Design and Development
JavaScript Examples 27-Apr-19.
JavaScript Examples 30-Apr-19.
JavaScript and Ajax (JavaScript Events)
Week 5: Recap and Portfolio Site
Barb Ericson Georgia Institute of Technology May 2006
JavaScript Examples 12-Jul-19.
Web Programming and Design
6.1 Introduction 6.2 Positioning Elements
JavaScript and HTML Simple Event Handling 26-Aug-19.
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

More on Events Some More Events Image Rollover Objects Select-Option List Control 1

More Events Moving a mouse pointer over some text – onMouseMove, onMouseDown, onMouseUp, onMouseOver, onMouseOut Changing Focus – onBlur, onFocus Entering Text – onKeyPress, onKeyDown, onKeyUp Choosing an item from a Select-Option list – onChange, onSelect, onBlur, onFocus 2

Simple Image RollOver Turn this…Into this… 3

Simple Image RollOver Code onMouseOver, onMouseOut inside swapImageOver() function: var myimage = document.getElementById("myimage"); myimage.src = "birthdayov.jpg"; 4

swapImageOver Function function swapImageOver() { var myimage = document.getElementById("myimage"); var myImageSrc = myimage.src; if (myImageSrc.indexOf("/birthday.jpg") >= 0) { myimage.src = "birthdayov.jpg"; } 5

swapImageOut Function function swapImageOut() { var myimage = document.getElementById("myimage"); var myImageSrc = myimage.src; if (myImageSrc.indexOf("/birthdayov.jpg") >= 0) { myimage.src = "birthday.jpg"; } 6

Exercise 6-1 Code a Mouse RollOver using the following images… UnBirthday UnBirthday_Over 7

Finding the Pointer Position onMouseDown function showpixels(event) { x=event.clientX y=event.clientY var myMsg = document.getElementById("msg"); myMsg.innerHTML = "X coords: " + x + ", Y coords: " + y; } … 8

Finding the Pointer Position onMouseMove function showpixels(event) { x=event.clientX y=event.clientY var myMsg = document.getElementById("msg"); myMsg.innerHTML = "X coords: " + x + ", Y coords: " + y; } … 9

Select-Option List Control Taking action from the select-list – "Opening" hidden divs – Opening new windows 10

Exercise 6-3 Click on the following Web page and the "Save AS a Complete Web Page" – Beatles Page Beatles Page Open up the HTML file in a Text Editor and remove the current JavaScript code Detect the x, y coordinates and determine which "Beatle's Square" you have clicked, display an alert() for John, Paul, George, Ringo depending on what you clicked 11

Example 12 Select "Condos" and open up hidden div… Code on next few slides…

DIV with SELECT-OPTION Select Property Type - Condos Houses Trailers 13

DIVs with Information Condos AnyStreet. San Marcos, CA Pine St. Escondido, CA Houses Main Street. Vista, CA Oak Street. Vista, CA … (more) 14

CSS for DIVs #selectdiv { position: absolute; left: 10px; top: 10px; width: 400px; height: 400px; } #mylist { position: absolute; left: 410px; top: 50px; width: 400px; height: 400px; background-color: white; } 15

JavaScript Code var myDiv; function showDiv() { var mySelect = document.getElementById("myselect"); var myList = document.getElementById("mylist"); switch (mySelect.value) { case 'C': myDiv = document.getElementById("condos"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; … continued next slide 16

JavaScript Code - continued case 'H': myDiv = document.getElementById("houses"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; case 'T': myDiv = document.getElementById("trailers"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; default: myList.style.display = "none"; //Makes div viewable break; } 17

Exercise 6-4 Make a Web page that looks like this Change the image when the user selects John, Paul, George, or Ringo 18

Opening a new Window 19 Select a News Site When selection is made, open new Window … code on next slide

HTML Code Select News Site - CNN Fox MSNBC 20

JavaScript Code function openNews() { switch (mySelect.value) { case 'C': open(" "_blank"); break; case 'F': open(" "_blank"); break; case 'M': open(" "_blank"); break; } 21

Exercise 6-5 Code the Last Example and get it to work. 22

End 23