Understanding JavaScript and Coding Essentials Lesson 8.

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 Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Javascript and the Web Whys and Hows of Javascript.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
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.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
JavaScript - A Web Script Language Fred Durao
1 JavaScript
JavaScript Syntax, how to use it in a HTML document
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
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.
JavaScript Challenges Answers for challenges
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Rich Internet Applications 3. Client JavaScript. Document Object Model (DOM) The DOM, is an interface that allows scripts or programs to access and manipulate.
Lesson 16. Practical Application 1 We can take advantage of JavaScript and the DOM, to set up a form so that the first text box of a form automatically.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to 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.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
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.
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
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.
4.1. Manage and maintain JavaScript Update the UI by using JavaScript. Understanding JavaScript and Coding Essentials.
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Introduction to.
Using DHTML to Enhance Web Pages
Week 3: Introduction to Javascript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Week 4: Introduction to Javascript
JavaScript is a programming language designed for Web pages.
Intro to JavaScript CS 1150 Spring 2017.
Section 17.1 Section 17.2 Add an audio file using HTML
JavaScript Functions.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript Introduction
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
JavaScript Basics What is JavaScript?
JavaScript and Ajax (JavaScript Events)
Web Programming and Design
Introduction to Web programming
Presentation transcript:

Understanding JavaScript and Coding Essentials Lesson 8

Exam Objective Matrix Skills/ConceptsMTA Exam Objectives Managing and Maintaining JavaScript Manage and maintain JavaScript. (4.1) Updating the UI by Using JavaScript Update the UI by using JavaScript. (4.2)

Introduction to JavaScript JavaScript is a programming language that provides action in applications. Interactivity enables an end user to take an action in an application, usually by clicking a button or pressing a key. A dynamic application adjusts and responds to such actions by end users. JavaScript also expands the opportunities to animate content.

Alert Boxes Alert boxes are commonly used to test the operation of JavaScript programs. Generally not used in production code. An alert box can help you ensure information is displayed to the user. A user has to click OK to close an alert box.

JavaScript Statements An ordinary JavaScript program is a sequence of statements. Statements are separated by semi-colons. alert('This is the first alert'); alert('This is the second alert');

Create a Simple JavaScript Application

Enabling JavaScript in a Web Browser Enabling JavaScript in Internet Explorer

Functions A function is a segment of a program defined and performed in isolation from other parts. JavaScript programmers sometimes identify functions that return no value as subroutines.

Functions (Continued) The expression of a function—the “function example1() {...}” part—doesn’t perform any of the code within the function. What you see in the source code is only the definition of a function. When the function is invoked, executed, or launched, something useful happen.

Function Example

Links between HTML and JavaScript Can include JavaScript code in tags in section of HTML file for small to medium-sized projects For large amounts of code, reference a separate JavaScript file within the tag:

Variables A JavaScript variable stands for a piece of data. You use the var syntax to define a new variable in JavaScript: var firstname;

Identifiers JavaScript identifiers are the names of variables and functions. Identifiers cannot be the same as keywords already used in JavaScript. For example, “if ” has a special meaning in JavaScript statements and is not available as a variable name.

JavaScript Libraries A library is collection of resources, like pre- written function code and subroutines, that developers use to create programs. A JavaScript library is pre-written JavaScript code. jQuery is the leading JavaScript library. Other popular libraries include Dojo, MooTools, and YUI.

JavaScript Libraries (Continued) When using a third-party library, include an element such as the following to reference the library:

getElementById() Method One important way to access display elements is with the getElementById() method. This method returns a reference to the first object with the specified id or NAME attribute.

getElementById() Example

Methods Methods are JavaScript functions that belong to objects. Methods differ from functions in that methods are always associated and used with a particular object. isNaN() is an example of a JavaScript function. –Tests for “not a number”; if value = 0 (false), value is a number document.getElementById() is an example of a JavaScript method; you can effectively only use getElementById with the special document object.

Events Events are actions that trigger other actions to occur. An event handler is an optional script or executable that handles input received in a program. Handlers are JavaScript code inside the tags (rather than the tags) that execute other JavaScript code in response to an event.

Events (Continued) A callback is a response to an event, such as a script execution in response to a mouse click.

onLoad Event Handler The onLoad event handler “belongs” to HTML items; it triggers when its owner is complete. The onLoad for an image occurs when the image is fully rendered and visible. The onLoad for a fires once all the cells in that table have been drawn.

onLoad Example

onLoad Example (Continued)

Flawed JavaScript Programs Are Erratic Flawed JavaScript programs are erratic—they give different results at different times. Reasons: –If the program depends on the existence of a particular screen element but doesn’t assure that the element exists –Launching the program at different times, resulting in slightly different loading order Fix: Begin calculations only after onLoad has fired.

Showing and Hiding Elements The HTML display attribute shows the user pertinent information and hides the information when no longer needed.

HTML display Attribute Example

HTML display Attribute Example (Cont.)

Updating the Content of Elements JavaScript uses the innerHTML property to change the current content of HTML elements (referred to as “inner content”) or insert new content.

innerHTML Example

innerHTML Example (Continued)

Recap Introduction to JavaScript –Alert boxes –JavaScript statements Creating a simple JavaScript application Functions Links between HTML and JavaScript Variables Identifiers JavaScript libraries Methods Events Showing and hiding elements Updating the content of elements