JavaScript Friend or Foe?. History of Java and JavaScript Oak and Coffee? ECMAscript European Computer Manufacturers Association JScript?

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Java Script Session1 INTRODUCTION.
Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
The Web Warrior Guide to Web Design Technologies
14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
1 HCI 201 JavaScript - Part 1. 2 Static web pages l Static pages: what we have worked with so far l HTML tags tell the browser what to do with the content.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
XP Creating Web Pages with HTML, 3e Prepared by: C. Hueckstaedt, Tutorial 8 1 New Perspectives on Creating Web Pages with HTML Tutorial 8: Programming.
Tutorial 11 Working with Operators and Expressions
JavaScript, Third Edition
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
XP 1 JavaScript Creating a Programmable Web Page.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
Week 9 PHP Cookies and Session Introduction to JavaScript.
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.
Chapter 3: Data Types and Operators JavaScript - Introductory.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Javascript. What is JavaScript? Scripting (interpreted) language designed for the web Beware: JavaScript is case sensitive.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
JavaScript Syntax, how to use it in a HTML document
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
MCA-401: ADVANCE JAVA 1 DEPTT. OF COMP. SC & APPLICATIONS PREPARED BY : NAVEEN NAGPAL (SENIOR ASSISTANT PROFESSOR)
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Client-Side Scripts JavaScript CIS January 2005.
1 JavaScript. 2 Introduction to JavaScript JavaScript was designed to add interactivity to HTML pages JavaScript is an interpreted programming (means.
Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across.
1 Server versus Client-Side Programming Server-SideClient-Side.
XP 1 JavaScript Creating a Programmable Web Page.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 2 New Perspectives on JavaScript, Comprehensive1 Working with Operators and Expressions Creating a New Year’s Day Countdown Clock.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Tutorial 11 1 JavaScript Operators and Expressions.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
XP Tutorial 3 New Perspectives on JavaScript, Comprehensive1 Working with Arrays, Loops, and Conditional Statements Creating a Monthly Calendar.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
Programming with JavaScript Maureen Smith Professor, Saddleback College CIM 271B - Tutorial 8.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
PHP using MySQL Database for Web Development (part II)
Creating a Programmable Web Page
>> Introduction to JavaScript
Tutorial 10 Programming with JavaScript
New Perspectives on Creating Web Pages with HTML
Objectives Insert a script element Write JavaScript comments
T. Jumana Abu Shmais – AOU - Riyadh
Tutorial 10 Programming with JavaScript
Tutorial 10: Programming with javascript
CIS 136 Building Mobile Apps
Intro to Programming (in JavaScript)
Presentation transcript:

JavaScript Friend or Foe?

History of Java and JavaScript Oak and Coffee? ECMAscript European Computer Manufacturers Association JScript?

What Side? Server-Side CGI Client-side JavaScript

Java vs. JavaScript Java More Complicated Requires JDK Programs compiled and saved as different files Powerful object language JavaScript Easy to learn and use No JDK Scripts right in HTML Simple Tasks

Running JavaScript Look on page Recommend you work through this commands Using the HEAD tag to your advantage.

Hiding JavaScript <!--hide script from browsers that don’t support javascript all your javascript cool commands //stop hiding from those browsers -->

Displaying Text document.write("First statement "); document.write("Second statement "); document.write("Third statement "); document.write(" "); document.writeln("First statement "); document.writeln("Second statement "); document.writeln("Third statement ");

Can I quote you on that? Single and double quotation marks for syntax: document.write("Come meet David ‘Bud’ Davis"); All JavaScript commands are case sensitive!!!

Variables and Data (8.11) Variable: a named element in a program used to store and retrieve data Given values with assignment operators var Year=2002; document.write(Year); document.write("The year is " + Year);

4 Types of Variable Values (Data Types) Number String Boolean variables Null value

Declaring a Variable (8.13) Month="December"; var Month; Month=“December”; var Month="December"; Notice the ;

Dates (Objects, not getting them) Data Objects: an object containing date information new (keyword) var SomeDay = new Date("June, 15, 2001, 14:25:00"); var SomeDay = new Date(2001, 5, 15, 14, 25, 0); Today = new Date();

Extracting Day Information (8.17) Need to now extract the information from Today Use a Method called getDate(); var Day = Today.getDate(); document.write(Day); Day will contain day of the month DateObject (Today) contains complete date and time information

Month and Year Information var Today = new Date(); var Month = Today.getMonth()+1 var Today = new Date(); var Year = Today.getYear();

The Y2K problem getYear() in Navigator 98, 99, 2000, 2001 in Explorer 98, 99, 100, 101

The Solution var Year = Today.getFullYear();

Expressions and Operators Expressions -- JavaScript commands that assign values to your variables Operators -- like + operator var ThisMonth = Today.getMonth()+1;

Expressions and Operators document.write("Only " + DaysLeft + " days until Christmas"); Look at table on 8.20

Operators Binary operators (work on two elements in an operation) Unary operators (work on one variable) Increment operators (increase variable by 1) Decrement operator Negation operator

Logical and Comparison Operators Comparison x < 100; y == 20; Logical (x < 100) && (y==20);

Logical and Comparison Operators Assignment Operators x = x + y; x += y; Both examples x variable is added to y and stored in x. x = x +2; x += 2;

JavaScript Functions (8.22) Way to save time and reuse script function function_name(parameters){ JavaScript Commands } {Command Block}

Action Function function ShowDate(date) { document.write("Today is " + date + " "); } in Web Page var Today = “04/20/02"; ShowDate(Today);

Placing Functions Definitions in : Interpreted before called Browser passes over command block until it is called in the HTML file...

Return of JavaScript Creating Arrays Working with Loops and Conditionals

Arrays (8.32) An ordered collection of values referenced by a single variable.

Weekday var Month = new Array(); Weekday[0]="Sunday"; Weekday[1]="Monday"; Weekday[2]="Tuesday"; Weekday[3]="Wednesday"; Weekday[4]="Thursday"; Weekday[5]="Friday"; Weekday[6]="Saturday";

Syntax var Month = new Array(); Month[11]="December"; Automatically Populated with null values

Example var Weekday = new Array(); Weekday[0]="Sunday"; Weekday[1]="Monday"; Weekday[2]="Tuesday"; Weekday[3]="Wednesday"; Weekday[4]="Thursday"; Weekday[5]="Friday"; Weekday[6]="Saturday"; var DayofWeek = Today.getDay(); document.write("Today is " + Weekday[DayofWeek]);

Loops (8.37) A set of instructions that is executed repeatedly... For While

For For(start; stop; update) { JavaScript Commands }

For... for(Num=1; Num<4; Num++) { document.write("The value of the Num is " + Num + " "); }

The value of the Num is 1 The value of the Num is 2 The value of the Num is 3

While while(condition) { JavaScript Commands }

While var Num=1 while(Num<4) { document.write("The value of the Num is " + Num); Num++ }

For versus While In the example the results are the same You would use a While loop in situations where no counter is available you want to run a loop while a condition exists

Conditional Statements [8.28] Runs only if certain conditions are met. if(condition) { JavaScript Commands }

Weekend? if(Day=="Friday"){ document.write("Have a nice weekend!"); }

Modulus Year % 4 == 0 (Evenly divisible by 4 -- No remainder) if(Year % 4 == 0) { MonthCount[2]=29; }

If... Else Structures [8.30] If(condition) { JavaScript Commands if true } else { JavaScript Commands if false }

Weekend or Work? if(Day=="Friday"){ document.write("Have a nice weekend!"); } else { if(Day=="Monday") { document.write("Ha-Ha"); } else { document.write("You're either enjoying your weekend or working toward it."); } Note: You'll want string on one line or break string up and use concatenation.

Recommendations Work through tutorial File can be downloaded off of resources page--Class/Course Technology Files Ask questions Help one another