Chapter 12: Objects CIS 275—Web Application Development for Business I.

Slides:



Advertisements
Similar presentations
JavaScript Chapter 7 Working with Strings. String Operations (Chap 2) var colors = red blue; var colors = red blue; var sizes = small large; var sizes.
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Session 8 JavaScript/Jscript: Objects Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
The Web Warrior Guide to Web Design Technologies
Page 1 of 26 Javascript/Jscript Ch 7,8,9,10 Vadim Parizher Computer Science Department California State University, Northridge Spring 2003 Slides from.
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.
20-Jun-15 JavaScript and HTML Simple Event Handling.
Lecture 1 Term 2 9/1/12 1. Objects You normally use the “.” Operator to access the value of an object’s properties. The value on the left of the “.” should.
Information Technology Center Hany Abdelwahab Computer Specialist.
1 JavaScript/Jscript 6 Objects. 2 Introduction Up till now –JavaScript used to illustrate basic programming concepts JavaScript can also –Manipulate every.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 12 - JavaScript: Objects Outline 12.1 Introduction 12.2 Thinking About Objects 12.3 Math Object.
Lesson15. JavaScript Objects Objects encapsulate data (properties) and behavior(methods); the properties and the methods of an object are tied together.
Introduction to scripting
Using Object-Oriented JavaScript CST 200- JavaScript 4 –
JavaScript Part 2 – Page 1 of 35CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: JavaScript Part 2.
Scripting Languages.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
1 JavaScript: Objects and Object Models October 25, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel,
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
JavaScript: Objects Outline 12.1 Introduction 12.2 Thinking About Objects 12.3 Math Object 12.4 String Object Fundamentals of Characters and Strings.
Data types, Literals (constants) and Variables Data types specify what kind of data, such as numbers and characters, can be stored and manipulated within.
Chapter 4 JavaScript and Dynamic Web pages. Objectives Static Web pages Dynamic Web pages JavaScript Variables Assignments. JavaScript Functions –(prompt(“”,””)
Objective Static vs. Dynamic Web pages. Variables. Assignments. JavaScript Hierarchy of Objects JavaScript Functions (prompt(“”,””) Document.write(“”)
Using Client-Side Scripts to Enhance Web Applications 1.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Lecture 9 The Basics of JavaScript Boriana Koleva Room: C54
 2008 Pearson Education, Inc. All rights reserved JavaScript: Objects.
M. Taimoor Khan Javascript Objects  Every data-type defined in Javascript is an object  It has a class definition for.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 13 – JavaScript/Jscript: Objects Outline 13.1Introduction 13.2Thinking About Objects 13.3.
Variety of JavaScript Examples Please use speaker notes for additional information!
CIS 375—Web App Dev II JavaScript III. 2 The String Object A JS String is an object with properties and _________. For more info on JavaScript click here.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
 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.
Chapter 10: JavaScript Functions CIS 275—Web Application Development for Business I.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 18 – JavaScript/Jscript: Objects Outline 18.1Introduction 18.2Thinking About Objects 18.3.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming control structures, events, objects.
Jaana Holvikivi 1 Introduction to Javascript Jaana Holvikivi Metropolia.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
CIS 375—Web App Dev II JavaScript I. 2 Introduction to DTD JavaScript is a scripting language developed by ________. A scripting language is a lightweight.
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.
Chapter 9: Control Statements II CIS 275—Web Application Development for Business I.
Chapter 5: Intro to Scripting CIS 275—Web Application Development for Business I.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Popup Boxes.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 - JavaScript: Objects Outline 12.1 Introduction 12.2 Thinking About Objects 12.3 Math Object.
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.
WEB SYSTEMS & TECHNOLOGY. Java Script  JavaScript created by Netscape  It is also client side programming  It can be use for client side checks.
Basic Objects. Math Object  Math.cos( x ), x in radians  Math.sqrt ( x )  Math.pow ( x, y )  Math.ceil( x )  etc.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Chapter 4 Java Script – Part2. 2 Location object Properties Properties href – whole path will be displayed. ex: window.location.href ( see example 11)
Java Script: Objects (Chapter 12 in [2]). 2 Outline Introduction Introduction Thinking About Objects Thinking About Objects Math Object Math Object String.
11 JavaScript: Objects.
CHAPTER 10 JAVA SCRIPT.
WEB APPLICATION PROGRAMMING
JavaScript: Objects.
Chapter 12 - JavaScript: Objects
WEB PROGRAMMING JavaScript.
Chapter 12 - JavaScript: Objects
Chapter 7 - JavaScript: Introduction to Scripting
JavaScript: Objects.
Chapter 12 - JavaScript: Objects
JavaScript: Introduction to Scripting
Presentation transcript:

Chapter 12: Objects CIS 275—Web Application Development for Business I

2 Thinking About Objects JavaScript is an object-_______ programming language (Math, Array, document, window, …). All objects have attributes and exhibit __________. Objects ____________ or enclose their attributes and behaviors. Programs communicate with objects through __________ (basically function calls). Objects possess the property of information ______. We don’t know (or care) how the object does things. We just care about what it does. Using existing objects makes programming easier. based behaviors encapsulate interfaces hiding

3 Math Object Rounding a number Rounding document.writeln(Math.round(7.25)) displays _____ The round method of the Math class has the argument ________ is a method of the document object. Math.PI is approximately _______________ Find the minimum of a series of numbersminimum Math.min(2, 4, 6, 7, 1) returns _____ Find the square root of a number Math.sqrt(49) returns ____ Raise a number to a power Math.pow(2, 8) returns _____ writeln

4 The String Object The String Object I JavaScript supports the set of characters called _________. For a string object, the length property returns the number of characters in the string. If lastname=“Johnson”, then lastname.length = ____ You can change the color of text using the fontcolor() method of the string object. document.write(" " + lastname.fontcolor(‘red’) + " ") The indexOf() method returns the starting position of text within a string object, beginning with 0. lastname.indexOf(“son”) = _____ 7 4 Unicode

5 The String Object The String Object II The match() method of the string object returns a substring if it exists. lastname.match(“son”) = _______ The substring(x, y) method returns a substring starting at position x for y characters. lastname.substring(0, 4) = ______ The toLowerCase() and toUpperCase() methods convert the characters in a string object to lower or upper case. lastname.toUpperCase() = _____________ See pp for more String methods. son John JOHNSON

6 Fig CharacterProcessing.html Character Processing Methods <!-- var s = "ZEBRA"; var s2 = "AbCdEfG"; document.writeln( " Character at index 0 in ‘ " + s + “ ' is " + s.charAt( 0 ) ); document.writeln( " Character code at index 0 in '" + s + "' is " + s.charCodeAt( 0 ) + " " ); document.writeln( " '" + String.fromCharCode( 87, 79, 82, 68 ) + "' contains character codes 87, 79, 82 and 68 " ) document.writeln( " '" + s2 + "' in lowercase is '" + s2.toLowerCase() + "'" ); document.writeln( " '" + s2 + "' in uppercase is '" + s2.toUpperCase() + "' "); // -->

7 Date ObjectDate Object I Create a date object (assume the date is 7/10/2002) var today = new Date() Methods for the date object today.getMonth() returns _____ today.getDate() returns _____ today.getFullYear() returns _______ You can also use getHours(), getMinutes, getSeconds() Check the interesting examples of displaying day, date, and time.day datetime

8 Date ObjectDate Object II You can create a date object and set the date: var aDate = new Date("October 12, :14:00") var aDate = new Date("October 12, 1988") var aDate = new Date(88,09,12,13,14,00) // Oct 12, 1:14 p var aDate = new Date(88,09,12) // Oct 12, 1988 var aDate = new Date(500) // in milliseconds You can reset parts of a date as follows: var today = new Date() today.setDate(today.getDate()-1) document.write(today.getDate() + " ")

9 Window ObjectWindow Object I Alert box Alert alert("Hello World!") Confirm box Confirm var name = confirm("Press a button") if (name == true) { document.write("You pressed OK") } else { document.write("You pressed Cancel") }

10 Window ObjectWindow Object II Prompt box Prompt var name = prompt("Please enter your name",“Right here") if (name != null && name != "") { document.write("Hello " + name) } Function to open two new windowsopen function openwindow() { window.open(" window.open(" } Sending to a new locationlocation location="

11 Window ObjectWindow Object III Refresh a document Refresh location.reload() Write text to the status barstatus window.status = "put your message here" Print a page Print window.print()

12 Frame Object Breaking out of a _________ Breaking out if (window.top != window.self) { window.top.location=“apage.htm" } Updating framesframes parent.upperframe.location.href="frame_b.htm" frame