Lesson 12- 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

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CIS101 Introduction to Computing Week 09 Spring 2004.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to scripting
CST JavaScript Validating Form Data with JavaScript.
Javascript and the Web Whys and Hows of Javascript.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
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.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
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.
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 JavaScript in Context. Server-Side Programming.
Using Client-Side Scripts to Enhance Web Applications 1.
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.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
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.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
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.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
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.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
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.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
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.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Introduction to.
Programming Web Pages with JavaScript
In this session, you will learn to:
Unit M Programming Web Pages with
Chapter 6 JavaScript: Introduction to Scripting
JavaScript is a programming language designed for Web pages.
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
Introduction to JavaScript
JavaScript Introduction
JavaScript an introduction.
DHTML Javascript Internet Technology.
A second look at JavaScript
WEB PROGRAMMING JavaScript.
DHTML Javascript Internet Technology.
Introduction to JavaScript
JavaScript Basics What is JavaScript?
JavaScript: Introduction to Scripting
Presentation transcript:

Lesson 12- Unit L Programming Web Pages with JavaScript

Why Javascript JavaScript can be used to enhance a Web page, and all such enhancements are rooted in looking up and/or changing data associated with parts of the HTML document. Can add interactivity to a web page. Can customize a web page. Can check validity of inputs. Client side processing. Do More With Less Code. Don't Reinvent The Wheel.

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.  DOM is designed to be language independent and to work with any programming language

HTML 5 and CSS 3 – Illustrated Complete

shady grove aeolian over the river, charlie dorian

Object Each HTML element in DOM is an object.  Specific object must be identified in order to manipulate it using JavaScript.

Property Each DOM node is associated with a set of information, and each piece of information is known as a property. Attributes are considered their own nodes and are associated with their own properties Commonly used properties: innerhtml the content of an object value the current value of another property

Method Action that can be performed for a node. Method names are followed by parentheses between which you specify information specific to the method Write add text content and / or code to a web page getElementById Locate an element with a given id value within the DOM tree Alert Opens a small alert box that displays a customized message.

A combination of objects, properties, and methods used to specify element in DOM that you want to access. Reference to DOM node begins with the document object getElementById method can specify node innerHTML property can get value of node Match the following: WhoinnerHTML WhatgetElementById

This piece of code creates a div element named "myDiv": This is the content of myDiv You can see what the innerHTML of the "myDiv" element looks like by using the following: javascript:alert(document.getElementById("myDiv").innerHTML);

YouTube - Introduction to HTML DOM  Good explanation YouTube - Document Object Model (DOM) Intro DOM – Reference information Core/core.html#ID

Dot notation connects all parts of statement into a single string. Objects, properties, and methods are listed in sequence, separated by a period document.getElementById(‘nameinput’).value

Even though the DOM trees look like they show parent/child relationships, the DOM is not a set data structure, but a model that specifies interfaces. The parent child relationships shown in a DOM are logical relationships and not representations of any type of internal data structures.

Scripts Can be used to add content to a Web page Statement – a 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 tags Spaces outside of quoted text are ignored Script tag can receive a language attribute, which is used to specify the scripting language used for the script

JavaScript interprets the end of a line as the end of a statement. Ending every statement with a semicolon makes code easier for developers to interpret. You may have one or may have a hundred statements between your begin and end script tags.

Code containing script that adds content

Event User action defined for Web pages. Can be linked to a script. Examples of HTML events: When a user clicks the mouse When a web page has loaded When an image has been loaded When the mouse moves over an element When an input field is changed When an HTML form is submitted When a user strokes a key

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.

Code containing event handler. What is the event?

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 Why put functions in a separate file?

Function code and code referencing function

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 Variable names are case sensitive, and must begin with a letter or an underscore character. var zip

When a function is called with the name of a variable included within the parentheses following the function name, the value of the variable is passed to the function. When text is to be rendered literally it must be included within quotes. However, when referring to a value of a variable, the variable name is used without quotes.

The concatenation operators are used to combine multiple string literals into a single string. What will each of these become if the name variable contains the value Fred? “You“+name+”may already be a winner!” “YouFredmay already be a winner!” “You “+name+” may already be a winner!” “You Fred may already be a winner!”

Code using a variable when validating form input If (name==null || name==“”) What does this mean?

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 message

Code for customizing text based on user input.

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

 W3schools innerhtml W3schools innerhtml  W3schools events W3schools events  W3schools getElementById W3schools getElementById

Code including script statements that generate placeholder text for older browsers.

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

Javascript examples javascript/main.html javascript/main.html Javascript madlib javascript/javascript-story.htm javascript/javascript-story.htm

CIS166 – Scripting Courses   CIS166AA - Introduction to Javascripting   CIS166AE - PHP HTML 5 and CSS 3 – Illustrated Complete