SYST 28043 Web Technologies SYST 28043 Web Technologies Lesson 6 – Intro to JavaScript.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Introducing JavaScript
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
The Web Warrior Guide to Web Design Technologies
SYST Web Technologies SYST Web Technologies Intro to PHP.
2440: 211 Interactive Web Programming JavaScript Fundamentals.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Information Technology Center Hany Abdelwahab Computer Specialist.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Javascript and the Web Whys and Hows of Javascript.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Database-Driven Web Sites, Second Edition1 Chapter 3 INTRODUCTION TO CLIENT-SIDE SCRIPTS.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
2440: 211 Interactive Web Programming Expressions & Operators.
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. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
1 JavaScript in Context. Server-Side Programming.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Using Client-Side Scripts to Enhance Web Applications 1.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
JavaScript - A Web Script Language Fred Durao
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
CSCI 2910 Client/Server-Side Programming
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming control structures, events, objects.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
1 JavaScript in Context. Server-Side Programming.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
This is our seminar JavaScript And DOM This is our seminar JavaScript And DOM.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
Java Script Introduction. Java Script Introduction.
>> Introduction to JavaScript
CHAPTER 10 JAVA SCRIPT.
Chapter 6 JavaScript: Introduction to Scripting
HTML & teh internets.
Introduction to Scripting
JavaScript Syntax and Semantics
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Chapter 19 JavaScript.
JavaScript Introduction
PHP.
JavaScript CS 4640 Programming Languages for Web Applications
Tutorial 10: Programming with javascript
Introduction to Programming and JavaScript
JavaScript: Introduction to Scripting
Web Programming and Design
Presentation transcript:

SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript

9/21/2015Wendi Jollymore, ACES2 JavaScript JavaScript is NOT Java! The syntax is similar JavaScript is a scripting language Client-side Object Oriented Has control structures, variables, etc.

9/21/2015Wendi Jollymore, ACES3 Using JavaScript In-Line Javascript Put JavaScript in document body Where you want results to appear In section of document Great for functions In external.JS file Store all your JavaScript in one or more files Refer to it in document when needed

9/21/2015Wendi Jollymore, ACES4 Tag Tag Used to put JavaScript in your document header or body Attributes: type=“text/javascript” language=“javascript” Deprecated src=“myscripts.js”

9/21/2015Wendi Jollymore, ACES5 Tag Tag <!-- // my statements and functions // go here // --> The comments keep script hidden from older browsers

9/21/2015Wendi Jollymore, ACES6 In-Line Scripts Put the script in tags where you want the output to appear Page last modified on: <!-- document.write(document.lastModified); // -->

9/21/2015Wendi Jollymore, ACES7 Scripts in Scripts in You can put scripts in the section If you want to refer to them more than once in your document If they contain functions used in other scripts in your document Use the tag in the tags

9/21/2015Wendi Jollymore, ACES8 Scripts in Scripts in Kaluha's Cat House <!-- function displayMsg() { alert("Welcome to the Cat House!"); } // -->

9/21/2015Wendi Jollymore, ACES9 External JavaScript Files Useful if you have many functions Useful when you use functions in more than one page Just type the scripts in plain text file Give the file a.js extension Usually saved in a /scripts sub- directory I’ll show you an example!

9/21/2015Wendi Jollymore, ACES10 JavaScript Coding Basics Variables & Data Types Operators Control Structures Functions

9/21/2015Wendi Jollymore, ACES11 Variables & Data Types Variables can be declared It’s good practice Use the var keyword You don’t have to specify data type var userName=""; var dateFlag = 1;

9/21/2015Wendi Jollymore, ACES12 Variables and Data Types Rules for Identifiers: identifier names are case-sensitive identifiers must start with a letter identifier names may not contain spaces identifiers must be made up of letters and numbers the only symbols allowed in identifier names are the underscore and $

9/21/2015Wendi Jollymore, ACES13 Variables & Data Types \bbackspace \fForm feed \nNew-line \rCarriage return \tTab \’Single-quote \”Double-quote \\Backslash alert("I said \"Click the button first!\" silly!"); document.write("Your location should be:\n\tC:\\webtech"); Escape Sequences

9/21/2015Wendi Jollymore, ACES14 Operators Arithmetic Operators + addition - subtraction *multiplication / division % modulus ++ unary increment -- unary decrement

9/21/2015Wendi Jollymore, ACES15 Operators Assignment Operators =equals += plus-equals -= minus-equals *= multiply-equals /= divide-equals %= modulus-equals

9/21/2015Wendi Jollymore, ACES16 Operators Relational Operators == equal to != not equal to >greater than >= greater than or equal to <less than <=less than or equal to Logical Operators &&AND Operator ||OR Operator !NOT Operator

9/21/2015Wendi Jollymore, ACES17 Control Structures If-Statements if (condition){ // code body } if (condition){ // code body } else { // code body }

9/21/2015Wendi Jollymore, ACES18 Control Structures Switch Statement switch (expression) { case value1: // code body break; case value2: // code body break; default: // code body }

9/21/2015Wendi Jollymore, ACES19 Iteration Pre-Test and Post-Test Loop while(condition) { // code body } do { // code body } while (condition);

9/21/2015Wendi Jollymore, ACES20 Iteration For Loops: for (init; condition; cont) { // code body } for (item in collectionType) { // code body }

9/21/2015Wendi Jollymore, ACES21 Defining Functions Function header Keyword function Function name Parameter list in brackets Or empty brackets if no params Params don’t need data types Return values Just add the return statement in the function

9/21/2015Wendi Jollymore, ACES22 Defining Functions function functionname(param1, param2,...) { // function body return value; // optional } Variable Scope Variables defined in a function are local to that function Define public variables outside functions

9/21/2015Wendi Jollymore, ACES23 Exercises Do the 3 quick exercises in the notes

9/21/2015Wendi Jollymore, ACES24 JavaScript Objects There are some pre-defined objects in JavaScript They include (these aren’t all of them) Date String Math Array We’ll look at the references for these on-line

9/21/2015Wendi Jollymore, ACES25 Exercises Do the three exercises in the notes that use JavaScript objects

9/21/2015Wendi Jollymore, ACES26 DOM Document Object Model W3C HTML standard for the structure of HTML documents Objects: Window Document Location History Each has various methods and properties you can use

9/21/2015Wendi Jollymore, ACES27 Event Handling Many elements and DOM objects have events Events = user manipulation of element/control/object You can associate code with an event When the event occurs, the code executes E.g. when user clicks a button, code in the “Click” event will execute See Event Reference online

9/21/2015Wendi Jollymore, ACES28 Common Tasks The notes on-line take you through some common, simple JavaScript tasks: Using Dialog Boxes Making a “Back” link Redirecting the User Working with Date/Time Form Validation Image Rollovers

9/21/2015Wendi Jollymore, ACES29 Exercise Go through the Common Tasks and try them all out We’ll do some of them together