Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

/ 251 Internet Applications Ahmed M. Zeki Sem – / Chapter 8.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
The Web Warrior Guide to Web Design Technologies
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Guide To UNIX Using Linux Third Edition
Introduction to scripting
4.1 JavaScript Introduction
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
 2004 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Introduction to JavaScript 11 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 14.
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.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
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.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
JavaScript - A Web Script Language Fred Durao
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
Introduction to JavaScript CS101 Introduction to Computing.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
XP Tutorial 8 Adding Interactivity with ActionScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
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.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
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.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
REEM ALMOTIRI Information Technology Department Majmaah University.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Chapter 6 JavaScript: Introduction to Scripting
JavaScript: Introduction to Scripting
Chapter 13 - JavaScript/JScript: Introduction to Scripting
Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
JavaScript: Introduction to Scripting
WEB PROGRAMMING JavaScript.
JavaScript: Introduction to Scripting
JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Presentation transcript:

Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting

Topics Covered Writing simple JavaScript programs. Using input and output statements Basic memory concepts. Arithmetic operators. Decision-making statements. Relational and equality operators.

Introduction JavaScript scripting language – Client-side scripting enhances functionality and appearance Makes pages more dynamic and interactive Pages can produce immediate response without contacting a server Customization is possible on the basis of users’ explicit and implicit input Browser has to have a built-in (JavaScript) interpreter – Foundation for complex server-side scripting

JavaScript: Object-Based Language There are three object categories in JavaScript: Native Objects, Host Objects, and User-Defined Objects. – Native objects: defined by JavaScript. String, Number, Array, Image, Date, Math, etc. – Host objects : supplied and always available to JavaScript by the browser environment. window, document, forms, etc. – User-defined objects : defined by the author/programmer Initially, we will use host objects created by the browser and their methods and properties

Scripting Two approaches to client side scripting: – Inline scripting Written in the section of a document – JavaScript code embedded in the section

Scripting tag Indicate that the text is part of a script type attribute – Specifies the type of file and the scripting language use: Value: “text/javascript” – IE and Netscape use JavaScript as default scripting language writeln method of the document object – Write a line in the document and position the cursor in the next line – Does not affect the actual rendering of the HTML document What is being written by JavaScript is the set of html instructions that in turn determine the rendering of the html document

Outline welcome.html (1 of 1)  HTML comment tags will  result in skipping of the script  by those browsers that do not  support scripting

Outline welcome2.html (1 of 1)  Escape character in combination with quotation mark: \” will result in insertion of a quotation mark in the string that is actually written by JavaScript

Outline welcome3.html 1 of 1  New line of the html document in a browser is determined by an html element

Outline welcome4.html 1 of 1  alert method of the window object displays a Dialog box

Common Escape Sequences

Dynamic Pages A script can adapt the content based on explicit input from the user or other information – System clock: Time of day – Hidden input – Cookies User input can be collected by invoking the prompt method of a window object – This will display a dialog box that prompts user for input

Outline welcome5.html (1 of 2) JavaScript is a loosely typed language. Variables take on any data type depending on the value assigned.   Value returned by the prompt method of the window object is assigned to the variable name  “+” symbol can be used for text concatenation as well as arithmetic operator

Outline

Fig. 7.7Prompt dialog displayed by the window object’s prompt method. This is the prompt to the user. This is the default value that appears when the dialog opens. This is the text field in which the user types the value. When the user clicks OK, the value typed by the user is returned to the program as a string. If the user clicks Cancel, the null value will be returned to the program and no value will be assigned to the variable.

Simple Script Example: Adding Integers The values of numbers to be added are obtained as user inputs colleted through the window.prompt method parseInt – Converts its string argument to an integer – What happens if the conversion is not done? See example on our web site NaN (not a number): value returned if non-numerical values are passed to the paresInt method

Outline Addition.html (1 of 2)

Outline Addition.html (2 of 2)

Arithmetic Operators and order of evaluation Always use parentheses to ensure desired order of evaluation: (a + b) / 6

Relational (Inequality and Equality) Operators   Do NOT confuse relational equality operator “==“ with an assignment operator “=“

Outline welcome6.html (1 of 3) “now” is a new instance of JavaScript native object D ate. It can invoke all the methods of that object class Note that conversion to integer type was not needed when the value was returned by the getHours method

Outline welcome6.html (2 of 3)

Outline welcome6.html (3 of 3)

Order of Precedence for the Basic Operators highest lowest