Intro to JavaScript. Use the tag to tell the browser you are writing JavaScript.

Slides:



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

The Web Warrior Guide to Web Design Technologies
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 7 Event-Driven.
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.
 JavaScript is a programming language that web browsers understand. You can use it to make your web pages interactive by: Responding to user actions and.
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.,
Web Programming – Java Script Association of Computing Activities Computer Science and Engineering Indian Institute of Technology Kanpur.
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.
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
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.
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.
JavaScript Part 1.
JavaScript 1. What is JavaScript? JavaScript allows web authors to create dynamic pages that react to user interaction. It is an Object-based because.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 3.
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.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
Introduction to Javascript. What HTML Can & Can Not Do HTML Can HTML Can Display text Display text Display images Display images Display even animated.
JavaScript - A Web Script Language Fred Durao
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.
1 JavaScript
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.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
JavaScript Challenges Answers for challenges
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Project Two Adding Scrolling Messages! Page 2.4 to 2.18 Today’s Agenda Look at scrolling message coding. Create a web page with a text box. Create a web.
Event Handling (the right way). A Simple Web Page Events - Summary The web page looks like this:
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.
CIS 228 The Internet 11/17/11 Of Timers and Cookies.
CSC 121 Computers and Scientific Thinking Fall Event-Driven Programming.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript 101 Lesson 6: Introduction to Functions.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Adding Interactivity Comp 140 Fall Web 2.0 Major change in internet usage –From mostly static pages Text Graphics Simple links –To new paradigm.
JavaScript JavaScript is a programming language that web browsers understand. You can use it to make your web pages interactive by: Responding to user.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
WEB SYSTEMS & TECHNOLOGY. Java Script  JavaScript created by Netscape  It is also client side programming  It can be use for client side checks.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Third lecture Event 27/2/2016 JavaScript Tutorial.
Event-Driven Programming
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Parts of Chapter 14 Key Concepts
JavaScript (JS) Basics
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
Event Driven Programming & User Defined Functions
Introduction to JavaScript
The Internet 11/15/11 Handling Data in JavaScript
Web Design and Development
Unit 6 part 6 Test Javascript Test.
Chapter 7 Event-Driven Pages
Barb Ericson Georgia Institute of Technology May 2006
Web Programming and Design
Presentation transcript:

Intro to JavaScript

Use the tag to tell the browser you are writing JavaScript

Making iRock interactive 1. Create the iRock webpage iRock - The Virtual Pet Rock irock.html

Making iRock interactive 2. Add a JavaScript alert to make iRock greet users

Alerting the user with a function Functions are reusable pieces of code that perform common tasks

Add the iRock greeting iRock - The Virtual Pet Rock The onload event is triggered when a page finishes loading. The alert() function is a built-in JavaScript function that display a text message in a small pop-up window.

Who Does What? Match each piece of JavaScript code to what it does.

Making iRock interactive 3. Write JavaScript that makes iRock ask for the user’s name, respond with a personal greeting and smile.

Add a function to get the user’s name function touchRock() { var userName = prompt("What is your name?", "Enter your name here."); if (userName) { alert("It is good to meet you, " + userName + "."); document.getElementById("rockImg").src = "rock_happy.png"; }

Add a function to get the user’s name function touchRock() { var userName = prompt("What is your name?", "Enter your name here."); if (userName) { alert("It is good to meet you, " + userName + "."); document.getElementById("rockImg").src = "rock_happy.png"; } prompt() is a function to pop up a box and get a value from the user

Add a function to get the user’s name function touchRock() { var userName = prompt("What is your name?", "Enter your name here."); if (userName) { alert("It is good to meet you, " + userName + "."); document.getElementById("rockImg").src = "rock_happy.png"; } Once we have a name, we greet the user persnally…

Add a function to get the user’s name function touchRock() { var userName = prompt("What is your name?", "Enter your name here."); if (userName) { alert("It is good to meet you, " + userName + "."); document.getElementById("rockImg").src = "rock_happy.png"; } …and change the rock image to a smiling rock

Add a function to get the user’s name function touchRock() { var userName = prompt("What is your name?", "Enter your name here."); if (userName) { alert("It is good to meet you, " + userName + "."); document.getElementById("rockImg").src = "rock_happy.png"; } prompt() is a function to pop up a box and get a value from the user Once we have a name, we greet the user personally… …and change the rock image to a smiling rock

Making iRock interactive 4. Add an event handler so that when a user clicks on the rock, the code in step 3 runs.

Make iRock ask for the user name Change the mouse cursor to a hand when hovering over the rock.

Make iRock ask for the user name The onclick event attribute of the rock image causes the touchRock() function to get called when the rock is clicked.

Make iRock ask for the user name The onclick event attribute of the rock image causes the touchRock() function to get called when the rock is clicked. Change the mouse cursor to a hand when hovering over the rock.

All together iRock - The Virtual Pet Rock function touchRock() { var userName = prompt("What is your name?", "Enter your name here."); if (userName) { alert("It is good to meet you, " + userName + "."); document.getElementById("rockImg").src = "rock_happy.png"; } <img id="rockImg" src="rock.png" alt="iRock" style="cursor:pointer" onclick="touchRock();" />