1 JavaScript: Objects and Object Models October 25, 2005 Slides modified from Internet & World Wide Web: How to Program. 2004 (3rd) edition. By Deitel,

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
Session 10 Dynamic HTML: Cascading Style Sheets™ (CSS), Object Model and Collections Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Objects.
 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.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
1 JavaScript/Jscript 6 Objects. 2 Introduction Up till now –JavaScript used to illustrate basic programming concepts JavaScript can also –Manipulate every.
Tutorial 14 Working with Forms and Regular Expressions.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic DHTML.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 12 - JavaScript: Objects Outline 12.1 Introduction 12.2 Thinking About Objects 12.3 Math Object.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
Tutorial 14 Working with Forms and Regular Expressions.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Tutorial 6 By Sam INE 1020 Introduction to Internet Engineering 1 DHTML & CSS Tutorial 6.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
JavaScript: Objects Outline 12.1 Introduction 12.2 Thinking About Objects 12.3 Math Object 12.4 String Object Fundamentals of Characters and Strings.
Creating an Animated Web Page
Working with Objects Creating a Dynamic Web Page.
CITS1231 Web Technologies JavaScript and Document Object Model.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
Chapter 8 Cookies And Security JavaScript, Third Edition.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
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.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
XP Tutorial 12 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Special Effects Creating Rollovers, Menus, Filters, and Transitions.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Objects.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 20 – Dynamic HTML: Object Model and Collections Outline 20.1Introduction 20.2Object Referencing.
DHTML: Working with Objects Creating a Dynamic Web Page.
Chapter 7: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content.
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
Internet & World Wide Web How to Program, 5/e. 2.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 18 – JavaScript/Jscript: Objects Outline 18.1Introduction 18.2Thinking About Objects 18.3.
CSS1 Dynamic HTML Objects, Collections & Events. CSS2 Introduction Dynamic HTML treats HTML elements as objects. Element’s parameters can be treated as.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 4 JavaScript.
Lesson 30: JavaScript and DHTML Fundamentals. Objectives Define and contrast client-side and server-side technologies used to create dynamic content for.
JavaScript: Objects 1 © by Pearson Education, Inc. All Rights Reserved.
JavaScript: Objects 1 © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 15 – Dynamic HTML: Object Model and Collections Outline 15.1Introduction 15.2Object Referencing.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
 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.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Chapter 13: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
Java Script: Objects (Chapter 12 in [2]). 2 Outline Introduction Introduction Thinking About Objects Thinking About Objects Math Object Math Object String.
DHTML.
11 JavaScript: Objects.
“Under the hood”: Angry Birds Maze
JavaScript Objects.
JavaScript: Functions
DHTML Javascript Internet Technology.
Chapter 12 - JavaScript: Objects
Chapter 13 - Dynamic HTML: Object Model and Collections
DHTML Javascript Internet Technology.
Chapter 12 - JavaScript: Objects
JavaScript: Objects.
Chapter 12 - JavaScript: Objects
COP 3813 Intro to Internet Computing
11 JavaScript: Objects.
Presentation transcript:

1 JavaScript: Objects and Object Models October 25, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel, and Goldberg. Published by Prentice Hall. ISBN

2 Chapter 12 - JavaScript: Objects Outline 12.1 Introduction 12.2 Thinking About Objects 12.3 Math Object 12.4 String Object Fundamentals of Characters and Strings Methods of the String Object Character-Processing Methods Searching Methods Splitting Strings and Obtaining Substrings XHTML Markup Methods 12.5 Date Object 12.6 Boolean and Number Objects 12.7 document Object 12.8 window Object 12.9 Using Cookies Final JavaScript Example Web Resources

Introduction Use JavaScript to manipulate every element of XHTML document from a script Reference for several of JavaScript’s built- in objects Demonstrates the capabilities

Thinking About Objects Objects –Attributes –Behaviors –Encapsulate date and methods –Property of information hiding –Details hidden within the objects themselves

5 Key Objects in JavaScript Key objects – Exhaustive list – String Date Math Number and Boolean

String Object JavaScript’s string and character- processing capabilities Appropriate for processing names, addresses, credit card information, etc Fundamentals of Characters and Strings –Characters Fundamental building blocks of JavaScript programs –String Series of characters treated as a single unit

Methods of the String Object Fig String object methods.

Methods of the String Object Fig String object methods.

Methods of the String Object

Character Processing Methods charAt –Returns the character at specific position charCodeAt –Returns Unicode value of the character at specific position fromCharCode –Returns string created from series of Unicode values toLowerCase –Returns lowercase version of string toUpperCase –Returns uppercase version of string

Searching Methods indexOf and lastIndexOf –Search for a specified substring in a string

Splitting Strings and Obtaining Substrings Tokenization –The process of breaking a string into tokens Tokens –Individual words –Separated by delimiters String.split() String.substr(start[, length]) and String.substring(indexA, indexB)

XHTML Markup Methods Anchor – Anchor Blink – blinking text Fixed – monospaced text Strike – strike out text Subscript – subscript Superscript – superscript

Date Object Provides methods for date and time manipulations

Date Object

Date Object

Date Object

Math Object Allow the programmer to perform many common mathematical calculations

Math Object Fig Math object methods.

Math Object

Math Object

Boolean and Number Objects Object wrappers for boolean true / false values and numbers

Boolean and Number Objects

Boolean and Number Objects

document Object Manipulate document that is currently visible in the browser window

document Object

window Object Provides methods for manipulating browser window

28 window.html 1 of 7

29 window.html 2 of 7

30 window.html 3 of 7

31 window.html 4 of 7

32 window.html 5 of 7

33 window.html 6 of 7

34 window.html 7 of 7

35

36

window Object

Using Cookies Cookie –Data stored on user’s computer to maintain information about client during and between browser sessions –Can be accessed through cookie property –Set expiration date through expires property –Use escape function to convert non-alphanumeric characters to hexadecimal escape sequences –unescape function converts hexadecimal escape sequences back to English characters –

39 cookie.html 1 of 4

40 cookie.html 2 of 4

41 cookie.html 3 of 4

42 cookie.html 4 of 4

43 Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing 13.3 Collections all and children 13.4 Dynamic Styles 13.5 Dynamic Positioning 13.6 Using the frames Collection 13.7 navigator Object 13.8 Summary of the DHTML Object Model

44 Objectives In this lesson, you will learn: –To use the Dynamic HTML Object Model and scripting to create dynamic Web pages. –To understand the Dynamic HTML object hierarchy. –To use the all and children collections to enumerate all of the XHTML elements of a Web page. –To use dynamic styles and dynamic positioning. –To use the frames collection to access objects in a separate frame on your Web page. –To use the navigator object to determine which browser is being used to access your page.

Introduction Dynamic HTML Object Model –Allows Web authors to control the presentation of their pages –Gives them access to all the elements on their pages Web page –Elements, forms, frames, tables –Represented in an object hierarchy Scripting –Retrieve and modify properties and attributes Referring to text –

Summary of the DHTML Object Model applets all anchors embeds forms filters images links plugins styleSheets scripts frames plugins collection body screen document history navigator location event document object window Key Fig DHTML Object Model.

Object Referencing The simplest way to reference an element is by using the element’s id attribute. The element is represented as an object –XHTML attributes become properties that can be manipulated by scripting

48

Collections all and children Collections –Arrays of related objects on a page –all all the XHTML elements in a document –children Specific element contains that element’s child elements

50 Outline all.html (1 of 2)

51 Outline

Dynamic Styles Element’s style can be changed dynamically Dynamic HTML Object Model also allows you to change the class attribute

53 Outline dynami cstyle. html (1 of 2)

54 Outline dynami cstyle2.html (1 of 2)

Dynamic Positioning XHTML elements can be positioned with scripting –Declare an element’s CSS position property to be either absolute or relative –Move the element by manipulating any of the top, left, right or bottom CSS properties

56 Outline

Using the frames Collection Referencing elements and objects in different frames by using the frames collection

58 Outline

59

navigator Object Netscape, Mozilla, Microsoft’s Internet Explorer –Others as well Contains information about the Web browser Allows Web authors to determine what browser the user is using

61 Outline navigat or.html (1 of 2)

Summary of the DHTML Object Model applets all anchors embeds forms filters images links plugins styleSheets scripts frames plugins collection body screen document history navigator location event document object window Key Fig DHTML Object Model.

Summary of the DHTML Object Model

Summary of the DHTML Object Model

Summary of the DHTML Object Model

66 Helpful references