HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.

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

Lesson 12- Unit L Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
Tutorial 16 Working with Dynamic Content and Styles.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 7 Event-Driven.
Tutorial 10 Programming with JavaScript
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Integrating JavaScript and HTML5 HTML5 & CSS 7 th Edition.
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.
Introduction to Applets CS 3505 Client Side Scripting with applets.
JavaScript, Fourth Edition
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
XP Tutorial 16 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
XP Tutorial 8 Adding Interactivity with ActionScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Introduction into JavaScript Java 1 JavaScript JavaScript programs run from within an HTML document The statements that make up a program in an HTML.
1 JavaScript in Context. Server-Side Programming.
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.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Understanding JavaScript and Coding Essentials Lesson 8.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Project 5: Customizing User Content Essentials for Design JavaScript Level Two Michael Brooks.
XP Tutorial 8 Adding Interactivity with ActionScript.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
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.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
CSC 121 Computers and Scientific Thinking Fall Event-Driven Programming.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
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.
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.
XML DOM Week 11 Web site:
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
JavaScript, Sixth Edition
Getting Started with CSS
Programming Web Pages with JavaScript
In this session, you will learn to:
Unit M Programming Web Pages with
Chapter 6 JavaScript: Introduction to Scripting
Tutorial 10 Programming with JavaScript
JavaScript is a programming language designed for Web pages.
Objectives Design a form Create a form Create text fields
Unit M Programming Web Pages with
Intro to JavaScript CS 1150 Spring 2017.
Section 17.1 Section 17.2 Add an audio file using HTML
Introduction to Scripting
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
A second look at JavaScript
Document Object Model (DOM): Objects and Collections
JavaScript Basics What is JavaScript?
Presentation transcript:

HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript

Objectives Explore the Document Object Model Add content using a script Trigger a script using an event handler Create a function HTML 5 and CSS 3 – Illustrated Complete

Objectives (continued) Store and compare data in variables Generate Web page content dynamically Script fallback options with Modernizr Integrate an existing script HTML 5 and CSS 3 – Illustrated Complete

Exploring the Document Object Model Document Object Model (DOM): standardized way of referring to parts of a Web page  Creates a hierarchical arrangement known as a DOM tree  Each part of HTML document represented by a node Object: HTML element in DOM  Specific object must be identified in order to manipulate it using JavaScript HTML 5 and CSS 3 – Illustrated Complete

Exploring the Document Object Model (continued) Property: piece of a standard set of information associated with DOM node  Attributes are considered their own nodes and are associated with their own properties Method: action that can be performed for a node  Method names are followed by parentheses between which you specify information specific to the method HTML 5 and CSS 3 – Illustrated Complete

Exploring the Document Object Model (continued) Combination of objects, properties, and methods used to specify element in DOM  Reference to DOM node begins with the document object getElementById method can specify nodegetElementById method can specify node innerHTML property can get value of nodeinnerHTML property can get value of node  Dot notation: connects all parts of statement into a single string Objects, properties, and methods are listed in sequence, separated by a periodObjects, properties, and methods are listed in sequence, separated by a period HTML 5 and CSS 3 – Illustrated Complete

Exploring the Document Object Model (continued) A DOM Tree HTML 5 and CSS 3 – Illustrated Complete

Adding Content Using a Script Scripts can be used to add content to a Web page  Statement: single script instruction Some goals can be achieved with one statement scriptsSome goals can be achieved with one statement scripts  Specify element and value using the getElementById method and innerHTML property  Script is placed in tags Spaces outside of quoted text are ignoredSpaces outside of quoted text are ignored HTML 5 and CSS 3 – Illustrated Complete

Adding Content Using a Script (continued) Code containing script and the resulting page HTML 5 and CSS 3 – Illustrated Complete

Triggering a Script Using an Event Handler Event: user action defined for Web pages  Can be linked to a script Event handler: HTML attribute that specifies a type of user action  Used to indicate that code should execute in response to specific type of user action  Allows Web page to respond to user activities HTML 5 and CSS 3 – Illustrated Complete

Triggering a Script Using an Event Handler (continued) Code containing event handler and resulting Web page HTML 5 and CSS 3 – Illustrated Complete

Creating a Function Function: chunk of script code with a name assigned to it  Code lines in function called as a single unit  Characters after // treated as comment Syntax: function name() { statement; } Function can be stored in external file  src attribute in script tag indicates location of script HTML 5 and CSS 3 – Illustrated Complete

Creating a Function (continued) Function code and code referencing function HTML 5 and CSS 3 – Illustrated Complete

Storing and Comparing Data in Variables Operators: symbols used to compare or change the values of objects or properties  Assignment operator (=)  Comparison operators: determine the size relationship between two values  Logical operators: logically connect multiple variables in a comparison Variable: used to store a value  Can be used in subsequent statements HTML 5 and CSS 3 – Illustrated Complete

Storing and Comparing Data in Variables (continued) JavaScript operators HTML 5 and CSS 3 – Illustrated Complete

Storing and Comparing Data in Variables (continued) Code using a variable when validating form input HTML 5 and CSS 3 – Illustrated Complete

Generating Web Page Content Dynamically JavaScript can be used to reconfigure Web pages based on user activities or inputs  Done by accessing, storing, manipulating, and writing values that are based on user input  Helps create Web pages customized in response to user inputs Example: specifying a user’s name, taken from a form field, when displaying a thank- you or greeting messageExample: specifying a user’s name, taken from a form field, when displaying a thank- you or greeting message HTML 5 and CSS 3 – Illustrated Complete

Generating Web Page Content Dynamically (continued) HTML 5 and CSS 3 – Illustrated Complete Code for customizing text based on user input and resulting page

Scripting Fallback Options with Modernizr Fallback options for some newer CSS and HTML features can be provided using JavaScript code  You can use Modernizr script elements to identify whether the current browser supports specific attributes Example: Modernizr.input.placeholderExample: Modernizr.input.placeholder Use conditional clauses, such as if statements, to cause fallback statements to be executed only if desired feature is not supported by current browserUse conditional clauses, such as if statements, to cause fallback statements to be executed only if desired feature is not supported by current browser HTML 5 and CSS 3 – Illustrated Complete

Scripting Fallback Options with Modernizr (continued) HTML 5 and CSS 3 – Illustrated Complete Code including script statements that generate placeholder text for older browsers

Integrating an Existing Script Many scripts for common tasks exist on the Web  Developers maintain Web sites where such scripts can be downloaded and are explained  It is possible to customize an existing script to perform a task rather than write a totally new one Make sure downloaded script comes from a reliable source and be sure you know exactly what it does before using itMake sure downloaded script comes from a reliable source and be sure you know exactly what it does before using it HTML 5 and CSS 3 – Illustrated Complete

Summary DOM is a way of referring to parts of a Web page Script code is created by combining DOM objects, properties, and methods, often using the dot notation Code for a single instruction in a script is known as a statement Scripts can be used to add contents to a page HTML 5 and CSS 3 – Illustrated Complete

Summary (continued) Scripts can be triggered in response to events Event handlers are used to link a script with a specific event A function is a block of code which is called as a single unit and has a name assigned to it  Has specific syntax  Used to simplify script structure HTML 5 and CSS 3 – Illustrated Complete

Summary (continued) Operators and variables are used to create more complex scripts JavaScript can be used to dynamically generate Web page content  In response to user actions or input JavaScript can be used to provide fallback options for older browsers Scripts for many common tasks are available on the Web HTML 5 and CSS 3 – Illustrated Complete