Introduction to Javascript. Web Page Technologies To create Web Page documents, you use: To create Web Page documents, you use: HTML – contents and structures.

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

The Web Warrior Guide to Web Design Technologies
JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
JavaScript- Introduction. What it is and what it does? What it is? It is NOT Java It is NOT Server-side programming Users can see code It is a client-side.
Information Technology Center Hany Abdelwahab Computer Specialist.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 1. Overview of Programming and JavaScript - 1
Introduction To JavaScript What JavaScript Is: a general purpose scripting language that allows a static page to interact with users and respond to events.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
JavaScript CMPT 281. Outline Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages.
Javascript and the Web Whys and Hows of Javascript.
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
JavaScript Part 1.
Internet Mark-up Languages CO32036 Part Lecture: Elementary JavaScript.
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.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
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
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
1 JavaScript
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
JavaScript Making Web pages come alive. Objectives Be able to read JavaScript scripts Be able to write JavaScript scripts.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
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 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
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.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
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.
Copyright © Terry Felke-Morris Web Development & Design Foundations with HTML5 8 th Edition CHAPTER 14 KEY CONCEPTS 1 Copyright.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Introduction to.
CGS 3066: Web Programming and Design Spring 2017
JavaScript is a programming language designed for Web pages.
Introduction to Javascript
Web Development & Design Foundations with HTML5 7th Edition
JavaScript.
14 A Brief Look at JavaScript and jQuery.
JavaScript an introduction.
DHTML Javascript Internet Technology.
Your 1st Programming Assignment
DHTML Javascript Internet Technology.
Introduction to JavaScript
CS105 Introduction to Computer Concepts
Web Design and Development
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
Web Programming– UFCFB Lecture 13
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

Introduction to Javascript

Web Page Technologies To create Web Page documents, you use: To create Web Page documents, you use: HTML – contents and structures HTML – contents and structures CSS – presentation, formatting CSS – presentation, formatting Programs (Javascript, ASP, php, etc.) – user interactivity, dynamic modification of pages Programs (Javascript, ASP, php, etc.) – user interactivity, dynamic modification of pages

What HTML Can & Can Not Do HTML Can HTML Can Display text Display text Display images Display images Display animated clipart Display animated clipart Allow users to input data Allow users to input data HTML Can Not HTML Can Not Do calculations Do calculations Display current date Display current date Check validity of input data Check validity of input data Respond to user actions Respond to user actions Be interactive Be interactive

Programming For a Web Page to be able to be interactive For a Web Page to be able to be interactive Calculate Calculate Display current date Display current date Check validity of input data Check validity of input data Add dynamic effects Add dynamic effects You need to include a program You need to include a program A set of detailed instruction to the computer to accomplish some task A set of detailed instruction to the computer to accomplish some task Using a programming language Using a programming language JavaScript JavaScript VBScript VBScript php php perl perl

What Is Javascript? (Now called EcmaScript) A scripting language used to add greater power and interactivity to Web pages A scripting language used to add greater power and interactivity to Web pages Freely combined with HTML in the Web document Freely combined with HTML in the Web document Invented by Netscape, now controlled by Ecma International Invented by Netscape, now controlled by Ecma International Often called a scripting language, rather than a programming language Often called a scripting language, rather than a programming language Distinct from Java, which is a full-fledged programming language invented by Sun Microsystems. Distinct from Java, which is a full-fledged programming language invented by Sun Microsystems.

Sample Web Page with Javascript Alert Demo (JS code) Alert Demo (JS code) Alert JS code Alert JS code Prompt Demo (JS code) Prompt Demo (JS code) Prompt JS code Prompt JS code Date Demo (JS code) Date Demo (JS code) Date JS code Date JS code

Other Examples of JS Use Create a new window on the fly. Create a new window on the fly. Create a new window on the fly Create a new window on the fly Check validity of form entries. Check validity of form entries. Check validity of form entries Check validity of form entries Manipulate document objects. Manipulate document objects. Manipulate document objects Manipulate document objects

Calling Functions Greet on Click (Code) Greet on Click (Code) Greet on ClickCode Greet on ClickCode Change Background on MouseOver (Code) Change Background on MouseOver (Code) Change Background on MouseOverCode Change Background on MouseOverCode Alert on Click (Code) Alert on Click (Code) Alert on Click Code Alert on Click Code

JS Demo function greet() { alert("Hello"); } Javascript ONCLICK Demo Greet on Click

JS Demo function toBlue() { document.bgColor="0000ff| } function toWhite() { document.bgColor="ffffff"; }... Change Background on MouseOver

... Javascript ONMOUSEOVER Demo </html

JS Demo function quote(mesg){ alert(mesg); } Famous Quotes Alert on Click

... </html

JS Demo Javascript Demo Where to Embed JS Function (1)

JS Demo function greet() { alert("Hello"); } Javascript ONCLICK Demo Where to Embed JS Function (2)

Javascript Language Basics

General Rules JS is case sensitive. JS is case sensitive. Sum = n1 + n2; // These statements are different sum = N1 + N2; Sum = n1 + n2; // These statements are different sum = N1 + N2; Statements end with a semicolon. Statements end with a semicolon. today = new Date(); today = new Date(); Comments Comments // This form is for short comments to end of line // This form is for short comments to end of line /* This form of delimiters can span several lines of comments. */ /* This form of delimiters can span several lines of comments. */

Variables firstName = "Maria"; // String value lastName = "Martinez"; // " myMotto = "Be Prepared"; // " myAge = 21; // integer value priceOfBook = 27.25; // float value priceOfCD = 18.50; // "

Operators // concatenation operator fulName = firstName + " " + lastName; // arithmetic operator totalPrice = priceOfBook + priceOfCD; // arithmetic operator ageOfMyBrother = myAge - 2;

Pre-defined Functions // current date and time today = new Date(); // year value (integer) of today year = today.getYear(); // pop up a window displaying alert("Welcome to Honolulu"); // prints string to the current page document.write("Hello."). document.writeln(" Good-bye");

User-defined Functions function greet() { alert("Welcome to Hawaii."); } function greetWithName(name) { alert("Welcome to Hawaii, " + name); } function changeBackColor(someColor) { alert("Here is a new background color."); document.bgColor = someColor; }

Events Event is an action external to the program that triggers a code to be executed. Event is an action external to the program that triggers a code to be executed. Partial List of Events Partial List of Events Event Works with When Onclick A, INPUT (e.g., button), FORM, TABLE, & many others an element is clicked

Event Works with When onblur A, AREA, BUTTON, INPUT, LABEL, SELECT, TEXTAREA the mouse leaves an element which was in focus onload BODY, FRAMESET a page is loaded into the browser ondblclick Same as ONCLICK an element is double-clicked onmouseover Same as ONCLICK mouse is moved over the element onmouseout Same as ONCLICK mouse is moved out of the element's area