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

Similar documents
EXERCISE: Introduction to client side JavaScript

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) What is JavaScript?

5/19/2015. Objectives. JavaScript, Sixth Edition. Introduction to the World Wide Web (cont d.) Introduction to the World Wide Web

Web Site Development with HTML/JavaScrip

JavaScript Programming

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

Javascript Lecture 23

Index LICENSED PRODUCT NOT FOR RESALE

JavaScript: Events, DOM and Attaching Handlers

A Balanced Introduction to Computer Science, 3/E

Working with JavaScript

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018)

React. HTML code is made up of tags. In the example below, <head> is an opening tag and </head> is the matching closing tag.

a Very Short Introduction to AngularJS

Overview. Event Handling. Introduction. Reviewing the load Event. Event mousemove and the event Object. Rollovers with mouseover and mouseout

JavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore

Web Development & Design Foundations with HTML5, 8 th Edition Instructor Materials Chapter 14 Test Bank

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

INLEDANDE WEBBPROGRAMMERING MED JAVASCRIPT INTRODUCTION TO WEB PROGRAMING USING JAVASCRIPT

CIW 1D CIW JavaScript Specialist.

Elementary Computing CSC 100. M. Cheng, Computer Science

JavaScript CS 4640 Programming Languages for Web Applications

Lesson 1: Writing Your First JavaScript

CSC Web Programming. JavaScript Browser Objects

Jquery.ajax Call Returns Status Code Of 200 But Fires Jquery Error

XML: Introduction. !important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... Directive... 9:11

Mobile Site Development

CNIT 129S: Securing Web Applications. Ch 12: Attacking Users: Cross-Site Scripting (XSS) Part 2

Elementary Computing CSC 100. M. Cheng, Computer Science

COURSE OUTLINE MOC 20480: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Working with Database. Client-server sides AJAX JSON Data formats Working with JSON data Request Response Bytes Database

AJAX: Rich Internet Applications

Course Details. Skills Gained. Who Can Benefit. Prerequisites. View Online URL:

5/19/2015. Objectives. JavaScript, Sixth Edition. Understanding the Browser Object Model and the Document Object Model. Objectives (cont'd.

EVENT-DRIVEN PROGRAMMING

Lesson 6: Introduction to Functions

Session 7. JavaScript Part 2. W3C DOM Reading and Reference

CSC Web Programming. Introduction to JavaScript

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11

Welcome to CS50 section! This is Week 10 :(

JavaScript 3. Working with the Document Object Model (DOM) and DHTML

ADDING FUNCTIONS TO WEBSITE

Task 1. Set up Coursework/Examination Weights

CISC 1600 Lecture 2.4 Introduction to JavaScript

JAVASCRIPT - CREATING A TOC

HTML, XHTML, and CSS. Sixth Edition. Chapter 1. Introduction to HTML, XHTML, and

Session 6. JavaScript Part 1. Reading

HTML5 - INTERVIEW QUESTIONS

ORB Education Quality Teaching Resources

Acknowledgments. Who Should Read This Book?...xxiv How to Read This Book...xxiv What s in This Book?...xxv Have Fun!...xxvi

Dynamism and Detection

XML. Jonathan Geisler. April 18, 2008

(Refer Slide Time: 01:40)

Understanding Angular Directives By Jeffry Houser

JavaScript Specialist v2.0 Exam 1D0-735

Introduction to JavaScript Programming Test Bank Chapter 1 with XML and PHP

E ECMAScript, 21 elements collection, HTML, 30 31, 31. Index 161

JavaScript CS 4640 Programming Languages for Web Applications

What is Java Script? Writing to The HTML Document. What Can JavaScript do? CMPT 165: Java Script

HTML 5 and CSS 3, Illustrated Complete. Unit K: Incorporating Video and Audio

Session 16. JavaScript Part 1. Reading

AIM. 10 September

Web Development & Design Foundations with HTML5

1. Setup a root folder for the website 2. Create a wireframe 3. Add content 4. Create hyperlinks between pages and to external websites

Working with Javascript Building Responsive Library apps

JOHNSON COUNTY COMMUNITY COLLEGE COURSE SYLLABUS WEB CRN Web Scripting: JavaScript I

October 08: Introduction to Web Security

Website Development Lecture 18: Working with JQuery ================================================================================== JQuery

A Brief Introduction to a web browser's HTML. and the Document Object Model (DOM) Lecture 28

Lesson 5: Introduction to Events

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:

JavaScript: Introduction to DOM and Attaching Handlers

Entry Level Assessment Blueprint Web Design

extensible Markup Language

XMLHttpRequest. CS144: Web Applications

A network is a group of two or more computers that are connected to share resources and information.

Announcements. Term Paper due on Wednesday at the beginning of class Midterm #2 next Monday Fawzi Emad, Computer Science Department, UMCP

PHP by Pearson Education, Inc. All Rights Reserved.

COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts

jquery Tutorial for Beginners: Nothing But the Goods

COMS 469: Interactive Media II

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

JavaScript. Like PHP, JavaScript is a modern programming language that is derived from the syntax at C.

CGS 3066: Spring 2015 JavaScript Reference

JavaScript II CSCI 311 SPRING 2017

CENG 256 Internet Programming Draft

A4: HTML Validator/Basic DOM Operation

Chapter 1 Introduction to HTML, XHTML, and CSS

Standard 1 The student will author web pages using the HyperText Markup Language (HTML)

Web Security: Vulnerabilities & Attacks

CSS Selectors. Web Authoring and Design. Benjamin Kenwright

Etanova Enterprise Solutions

So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object.

Why Use A JavaScript Library?

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

jquery and AJAX

CS50 Quiz Review. November 13, 2017

JavaScript is described in detail in many books on the subject, and there is excellent tutorial material at

Transcription:

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

Objectives (continued) Store and compare data in variables Generate Web page content dynamically Script fallback options with Modernizr Integrate an existing script

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

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

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 node innerhtml 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 period

Exploring the Document Object Model (continued) A DOM Tree

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 scripts Specify element and value using the getelementbyid method and innerhtml property Script is placed in <script> tags Spaces outside of quoted text are ignored

Adding Content Using a Script (continued) Code containing script and the resulting page

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

Triggering a Script Using an Event Handler (continued) Code containing event handler and resulting Web page

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

Creating a Function (continued) Function code and code referencing function

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

Storing and Comparing Data in Variables (continued) JavaScript operators

Storing and Comparing Data in Variables (continued) Code using a variable when validating form input

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 thankyou or greeting message

Generating Web Page Content Dynamically (continued) 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.placeholder Use conditional clauses, such as if statements, to cause fallback statements to be executed only if desired feature is not supported by current browser

Scripting Fallback Options with Modernizr (continued) 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 it

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

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

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