Introduction to JavaScript Programming. World Wide Web Original purpose was locating and displaying information Small academic and scientific community.

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.
Java Script Session1 INTRODUCTION.
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
Multimedia and the World Wide Web HCI 201 Lecture Notes #8B.
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.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Information Technology Center Hany Abdelwahab Computer Specialist.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
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 scripting
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Javascript and the Web Whys and Hows of Javascript.
4.1 JavaScript Introduction
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Introduction to JavaScript 11 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 14.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Generations of Programming Languages First generation  Machine Language Second Generation  Assembly Language Third Generation  Procedural language such.
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.
1 CLIENT-SIDE SCRIPTS. Objectives 2 Learn how to reference objects in HTML documents using the HTML DOM and dot syntax Learn how to create client-side.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
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.
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 AND DOM Internet Engineering Spring 2012.
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.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 14 JavaScript.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
JavaScript - A Web Script Language Fred Durao
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part One.
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.
1 JavaScript in Context. Server-Side Programming.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
Introduction to HTML Simple facts yet crucial to beginning of study in fundamentals of web page design!
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 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
“Under the hood”: Angry Birds Maze
JavaScript is a programming language designed for Web pages.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
Chapter 19 JavaScript.
JavaScript an introduction.
WEB PROGRAMMING JavaScript.
T. Jumana Abu Shmais – AOU - Riyadh
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
Web Programming and Design
Presentation transcript:

Introduction to JavaScript Programming

World Wide Web Original purpose was locating and displaying information Small academic and scientific community Commercial applications Static HTML Need for more interactive and appealing

JavaScript Joint venture – Sun & Netscape Netscape Communications LiveScript Sun Microsystems Simplify its Java language Open language – anyone can use Embedded in the HTML document

JavaScript vs. Java Java is full-fledged, object-oriented language Can be used to create applets Applets – small programs designed to execute within another application Must use some type compiler, such as Sun’s JDK

JavaScript Statements/variables are case sensitive Interpreted language – code runs only on a JS interpreter built into browser Version of JS depends on browser version IE supports additional features – Microsoft calls its version Jscript Older browsers may not handle newer JS codes

JavaScript and HTML Tags HTML (hypertext markup language) Microsoft FrontPage Macromedia Dreamweaver Microsoft Word Netscape Composer Text editor, such as Notepad Tag – instruction surrounded by ‘ ’ symbols The instructions are call attributes and have values assigned to them

JavaScript and HTML Tags TagAttributes TagAttributes

SCRIPT Tags Four attributes LANGUAGE – identifies version of JavaScript SRC – text string for URL/filename of JS source file TYPE – specify the scripting language DEFER – beyond the scope

SCRIPT Tags <!– Hide from old browsers Place your JS code in this area //--> TagAttributes

HTML Comments Embedded JS code needs to be hidden from incompatible browsers <!-- beginning comment block --> ending comment block

JavaScript Comments Line Comments // This is a line comment Block Comments /* Beginning line Still a comment Ending line */

JavaScript Benefits Web Standard Alternative – Microsoft VBScript Follows Visual Basic syntax VBScript not supported in Netscape Navigator Provide instant feedback without CGI (Common Gateway Interface) scripts

JavaScript Cookies Cookies – data sent and stored in files on user’s computer Navigator – cookies.txt IE – Cookies folder Track user’s preferences JavaScript code limits access to user’s hard drive – browser controls cookie location

JavaScript Basics Common types of variables Numeric - numbers Strings - letters Boolean – true/false or yes/no

JavaScript Basics Variables – Naming Conventions Name must begin with letter or underscore Rest of name – letters, numbers, or underscores Avoid reserved words (appendix A) No spaces or punctuation Variables are case sensitive Defined by keyword var

JavaScript Basics Literal – actual number or char text, rather than a calculated result or value input from a keyboard var browserType = “Netscape” var width = 3 var Test = “\”Hey there!\” she said.” Special characters (table I-2): String literal:

JavaScript Basics write() – method used to write text to the Web page alert() – method used to display messages in a dialog box Discussed in more detail in Project 1

JavaScript Basics Expression – formula to assign values to variables average = totalValue/Count var Count = 0

JavaScript Basics Arithmetic operators – Table I-3 Increment/decrement – Table I-4 Arithmetic expressions – Table I-5 Mathematical order – Table I-6 Concatenation

Conditionals Allow comparisons of values See Table I-7 If and While statements

Conditionals var todaysDate = new Date() var numHours = todaysDate.getHours() if(numHours >= 12) { document.write(“Good Afternoon”) } else { document.write(“Good Morning”) } the rest of your code…

Conditionals while (condition) { the JavaScript code to be executed while the condition is True } the JavaScript code to be executed when the loop is finished

Functions Way to write several lines of script and use them repeatedly as needed function Greetings() { alert(“Hello, this is a friendly message.”) } messageStr = “This is a customized message.” function Greetings(messageStr) { alert(messageStr) } All-purpose message:

Objects, Properties, and Methods Object – real-world entity (book, car) JS is object oriented (OO) Object-Oriented Programming (OOP) Object is described by its properties Properties are attributes that help differentiate one object from another Separate object and property with a period Ex. car.color = “red”

Objects, Properties, and Methods Method – function or action you want the object to perform (behavior) Ex. car.drive() Some methods require an argument Argument is a value passed to the method

Objects, Properties, and Methods JS uses many objects, but not a complete OOP language JS provides many built-in objects Ex. Date, Arrays, windows, and forms JS allows you to define and create your own When defining objects, assign unique and meaningful names (not form1)

Events Action that occurs, such as a user clicking a link or button, or user entering data in a form textbox JS reacts to events by Event Handlers Table I-8 JavaScript Quick Reference (page J A.5) Events are “triggered” Ex. onMouseOver

Events:Forms Many event handlers work with forms Ex. onFocus, onBlur, onChange, onSubmit, and onReset

Frames Frame is a feature that allows a browser window to be split into smaller units.

Arrays Collection of data items identified by a singular name Defined by using built-in Array object var currMonth = new Array(13) currMonth[1] = “January” currMonth[2] = “February” … currMonth[12] = “December” Length

Arrays Thirteen (13) elements defined because JS first array element is [0] Older browsers use [0] to hold the length Good practice to leave element [0] empty and start with element [1] Creating arrays discussed in Project 3