Learn JavaScript / PDF


Learn JavaScript / PDF
Learn JavaScript / PDF







Table of Contents





Lesson 1: Introduction to JavaScript....................................................................................... 1-1
Pre-Assessment Questions........................................................................................................ 1-2
Introduction to Scripting ........................................................................................................... 1-3
Origins of JavaScript................................................................................................................. 1-3
JavaScript Characteristics ......................................................................................................... 1-3
JavaScript and Common Programming Concepts .................................................................... 1-6
Java and JavaScript ................................................................................................................... 1-7
Server-Side vs. Client-Side Applications ............................................................................... 1-10
Annotating Your Code with Comments ................................................................................. 1-15
Lesson 1 Review..................................................................................................................... 1-21
Lesson 2: Working with Variables and Data in JavaScript................................................... 2-1
Pre-Assessment Questions........................................................................................................ 2-2
Using JavaScript to Communicate with the User ..................................................................... 2-4
Using Data More Than Once: Variables................................................................................. 2-15
JavaScript Expressions............................................................................................................ 2-21
Operators................................................................................................................................. 2-22
Inline Scripting, Simple User Events and the onLoad and onUnload Event Handlers........... 2-29
Keywords and Reserved Words.............................................................................................. 2-30
Lesson 2 Review..................................................................................................................... 2-34

Lesson 3: Functions, Methods and Events in JavaScript....................................................... 3-1
Pre-Assessment Questions........................................................................................................ 3-2
Functions................................................................................................................................... 3-4
Defining a Function .................................................................................................................. 3-4
Calling a Function..................................................................................................................... 3-7
User Events and JavaScript Event Handlers........................................................................... 3-21
Methods as Functions ............................................................................................................. 3-22
Lesson 3 Review..................................................................................................................... 3-26

Lesson 4: Controlling Program Flow in JavaScript ............................................................... 4-1
Pre-Assessment Questions........................................................................................................ 4-2
Controlling Decisional Program Flow...................................................................................... 4-5
The if...else Statement............................................................................................................... 4-5
The while Statement ............................................................................................................... 4-12
The do...while Statement ........................................................................................................ 4-16
The for Statement.................................................................................................................... 4-17
The break Statement ............................................................................................................... 4-21
The continue Statement........................................................................................................... 4-23

The switch Statement.............................................................................................................. 4-26
Lesson 4 Review..................................................................................................................... 4-31

Lesson 5: The JavaScript Object Model.................................................................................. 5-1
Pre-Assessment Questions........................................................................................................ 5-2
The JavaScript Object Model.................................................................................................... 5-3
Commonly Used Objects .......................................................................................................... 5-5
The window Object................................................................................................................... 5-5
The document Object.............................................................................................................. 5-21
The with Statement ................................................................................................................. 5-25
The image Object.................................................................................................................... 5-31
The history Object................................................................................................................... 5-40
The location Object................................................................................................................. 5-41
The navigator Object............................................................................................................... 5-43
Lesson 5 Review..................................................................................................................... 5-47

Lesson 6: JavaScript Language Objects.................................................................................. 6-1
Pre-Assessment Questions........................................................................................................ 6-2
Introduction to JavaScript Language Objects ........................................................................... 6-4
The String Object...................................................................................................................... 6-4
Additional String Object Methods.......................................................................................... 6-14
Evaluating Strings................................................................................................................... 6-14
JavaScript Regular Expressions.............................................................................................. 6-24
The Array Object .................................................................................................................... 6-28
The Date Object ...................................................................................................................... 6-34
Setting and Extracting Time Information ............................................................................... 6-41
The Math Object ..................................................................................................................... 6-45
Lesson 6 Review..................................................................................................................... 6-50

Lesson 7: Developing Interactive Forms with JavaScript...................................................... 7-1
Pre-Assessment Questions........................................................................................................ 7-2
Interactive Forms ...................................................................................................................... 7-3
Overview of Form Elements..................................................................................................... 7-3
Referring to a Form Element .................................................................................................... 7-5
The form Object........................................................................................................................ 7-5
The button Object ..................................................................................................................... 7-7
The checkbox Object ................................................................................................................ 7-9
The text and textarea Objects.................................................................................................. 7-12
The radio Object ..................................................................................................................... 7-19
The select Object..................................................................................................................... 7-23
Multiple-Selection Lists.......................................................................................................... 7-31
Form Validation ...................................................................................................................... 7-33
Lesson 7 Review..................................................................................................................... 7-36

Lesson 8: Cookies and JavaScript Security............................................................................. 8-1
Pre-Assessment Questions........................................................................................................ 8-2
Security and Cookies in JavaScript........................................................................................... 8-3
What Are Cookies? ................................................................................................................... 8-3
How Are Cookies Sent?............................................................................................................ 8-4
© 2002 ProsoftTraining All Rights Reserved. Version 5.07
EVALUATION COPY
vii
Who Can Send Cookies? .......................................................................................................... 8-5
Storing Cookies......................................................................................................................... 8-6
Why Use Cookies?.................................................................................................................... 8-8
Assigning a Cookie ................................................................................................................... 8-9
Testing for Cookie Presence ................................................................................................... 8-10
Clearing a Cookie ...................................................................................................................

Controlling Cookies in the Browser ....................................................................................... 8-10
JavaScript Security Issues....................................................................................................... 8-23
Lesson 8 Review..................................................................................................................... 8-29

Lesson 9: Controlling Frames with JavaScript....................................................................... 9-1
Pre-Assessment Questions........................................................................................................ 9-2
Using JavaScript with Frames and Windows ........................................................................... 9-3
Targeting Frames with JavaScript ............................................................................................ 9-3
Changing Two or More Frames with JavaScript .................................................................... 9-10
Frames, Functions and Variables............................................................................................ 9-11
Targeting Windows with JavaScript....................................................................................... 9-14
Windows, Functions and Variables ........................................................................................ 9-15
Lesson 9 Review..................................................................................................................... 9-21

Lesson 10: Custom JavaScript Objects.................................................................................. 10-1
Pre-Assessment Questions...................................................................................................... 10-2
Creating Custom Objects ........................................................................................................ 10-3
Custom Object Demonstration................................................................................................ 10-3
Creating a JavaScript Object: The Constructor ...................................................................... 10-3
Creating an Instance of a Custom Object ............................................................................... 10-5
Creating Object Methods ........................................................................................................ 10-6
Creating Functions for Your Objects.................................................................................... 10-10
Complex Custom Objects ..................................................................................................... 10-18
Lesson 10 Review.................................................................................................................








download Learn JavaScript / PDF

Learn JavaScript / PDF



0 commentaires: