`
`Page 1Page 1
`
`Google Exhibit 1018
`Page 1
`
`
`
`Javascript on the Web
`
`Check out the following sites for JavaScript tools and information:
`
`Netscape
`URL: http://www.netscape.com/
`
`Best ofSite: Information on future releases of]avaScript, official ]aVaScript Authoring Guide
`For the ]avaScript Authoring Guide, go to http: //home . netscape . com/eng/mozilla/3 . 0/
`handbook/javascript/index.html.
`
`For the latest on JavaScript 1.2, go to http: //developernnetscape.com/library/
`documentation/.
`
`For]avaScript developer information, go to http: //developer. net scape.com/.
`
`Microsoft
`
`URL: http: //www.microsoft.com/
`
`Best of Site: ActiVeX Controls, }Script information, Script Debugger, ActiveX Control
`Pad
`
`To download the latest version of]Script_. go to http://www.microsoft.com/msd0wnload/
`sor‘J‘.pting.htm.
`
`Acadia Infuse Home Page
`
`URL: http: //wwvv. acad:'Lans.com/infuse
`
`Best of Site: Acadia Infuse home page, ]avaScript news
`
`Javascript Tip of the Week
`URL: http: //www.webr*eference . com/javascript/
`
`Best of Site: Practical examples of]avaScript
`
`For more sites on ]aVaScript, turn to Appendix D, “]avaScript Resources on the Internet.”
`
`Google Exhibit 1018
`Page 2
`
`
`
`What's New iii This Edition
`
`One of the highlights of this edition is the inclusion of Acadia Soitware’s Infuse, a
`]aVaScript development tool, on the CD—ROM. lfichard Wagner shows you how to use
`Infuse to create]avaScript scripts in step—by—stcp examples in an all—new chapter. Netscape’s
`new dynamic HTML technologies, layers and]avaScript style sheets, are also explored in
`depth. You can use ]avaScript with these new features to add a dynamic look and feel to
`your Web page. This edition also explores other new ]aVaScript 1.2 capabilities that are
`supported in Netscape Communicator 1.0.
`
`One of the most frustrating issues developers face when working with ]avaScript is deter
`mining whether a particular language element is supported in a certain browser or a
`particular release. This edition contains an easy-to—decipher list to help you resolve com-
`patibility issues. You’ll also see examples of how to write relatively global scripts.
`
`Throughout this edition, we’ve also highlighted new objects, methods, and properties of
`the language, as well as new tools, such as Microsoffs Script Debugger. Many of the
`important version differences appear in note boxes to help you find them as you read.
`
`Google Exhibit 1018
`Page 3
`
`
`
`Richard \Vagner, et al.
`
`sams
`net V
`
`201 West 103rd Street
`
`Indianapolis, IN 46290
`
`Google Exhibit 1018
`Page 4
`
`
`
`Copyright © I997 by Sams.net Publishing
`SECOND EDITION
`
`All rights reserved. No part of this book shall be reproduced, stored in a
`retrieval system, or transmitted by any means, electronic, mechanical,
`photocopying, recording, or otherwise, without written permission from the
`publisher. No patent liability is assumed with respect to the use of the
`information contained herein. Although every precaution has been taken in
`the preparation of this book, the publisher and author assume no responsi-
`bility for errors or omissions. Neither is any liability assumed for damages
`resulting from the use of the information contained herein. For informa-
`tion, address Samsnet Publishing, 201 W. 103rd St., Indianapolis, IN
`46290.
`
`International Standard Book Number: I~5752I—306—0
`
`Library of Congress Catalog Card Number: 97—65-454
`
`2000
`
`99
`
`93
`
`97
`
`4321
`
`Interpretation of the printing code: the rightmost double—digit number is
`the year of the book’s printing; the rightmost singlc—digit, the number of the
`book’s printing. For example, a printing code of 97—I shows that the first
`printing of the book occurred in 1997.
`
`Compared in AGa1-anzond and MCPa’igz'tal by Macmillan Computer
`Publishing
`
`Printed in the United States of/l merim
`
`Trademarks
`
`All terms mentioned in this book that are known to be trademarks or service
`marks have been appropriately capitalized. Sarns.net Publishing cannot
`attest to the accuracy of this information. Use of a term in this book should
`not be regarded as affecting the validity of any trademark or service mark.
`)avaScript is a trademark of Sun Microsystems.
`
`Publisher and President Richard K Swnzlley
`Rosemarie Graham
`
`Publishing Manager
`
`Director of Editorial Services
`
`Managing Editor
`
`Cinily Morrow
`Brice P. Gosnell
`
`Director of Marketing
`
`Kelli 5. Spencer
`
`Product Marketing Manager
`Assistant Marketing Manager I
`
`ll’/endy Gilhrialc
`I Rachel Wolfe
`
`Acquisitions Editor
`Corrine Wm
`
`Development Editor
`Marla Reece
`
`Software Development Specialist
`john W/nrriner
`
`Production Editor
`
`Gayle L johnson
`
`Copy Editors
`Margaret Berson
`Chuck Hutchinson
`
`Indexer
`Chris W/ilcox
`
`Technical Reviewer
`Blake Hall
`
`Editorial Coordinator
`Kntie W/ire
`
`Technical Edit Coordinator
`
`Lorraine Schzzfiirr
`
`Resource Coordinator
`
`Deborah Frishy
`
`Editorial Assistants
`Carol Ac/eermzzn
`Andi Richter
`Rhonda Tinch—Mize
`
`Cover Designer
`fnson Gris/nzrn
`
`Book Designer
`Gary Adnir
`
`Copy Writer
`David Reichwein
`
`Production Team Supervisors
`Brad Chinn
`
`Charlotte Clap];
`
`Production
`
`Georgrfnmz Brigg:
`Cyndi Davis
`Ian A. Smith
`
`Mary Ellen Stephenson
`
`Google Exhibit 1018
`Page 5
`
`
`
`Overview
`
`Introduction
`
`xxix
`
`Getting Siaried with Javascripi
`
`JavaScript and the World Wide Web
`
`3
`
`How ]avaScript and HTML Work Together
`
`31
`
`Assembling Your ]avaScript Toolkit
`
`53
`
`Using Acadia Infuse to Create ]avaScript Scripts 67
`
`The Javascripl language
`
`Fundamentals of the ]avaScript Language
`
`89
`
`Operators
`
`117
`
`Control Structures and Looping
`
`139
`
`Functions
`
`159
`
`Javascripl Obieds
`
`The ]avaScript Object Model
`
`179
`
`Handling Events
`
`217
`
`Navigator Objects
`
`243
`
`Document Objects
`
`311
`
`Form Objects
`
`337
`
`Built-In Language Objects
`
`369
`
`Creating Custom ]avaScript Objects
`
`403
`
`Visual Programming Techniques
`
`Creating Special Effects with JavaScript
`
`425
`
`Controlling Layers with JavaScript
`
`445
`
`]avaScript Style Sheets
`
`461
`
`Programming Techniques
`
`Site Navigation with ]avaScript
`
`485
`
`Forms and Data Validation
`
`507
`
`Using Ciient—Side Tables in ]avaScript
`
`547
`
`Error Handling and Debugging in ]avaScript
`
`565
`
`Google Exhibit 1018
`Page 6
`
`
`
`Advanced Jnvnscripl
`
`23 ]avaScript Compatibility Issues
`
`595
`
`24 ]avaScript and Web Security
`
`609
`
`25 Cookies and State Maintenance
`
`633
`
`Jnvnscripi Connectivity
`
`26 LiveConnect: Integrating JavaScript and Java
`
`659
`
`27 ActiveX Scripting
`
`683
`
`28 Working with Netscape Plug—Ins
`
`705
`
`29 LiveAudio and Multimedia 731
`
`Purl VIII Server-Side Jnvnscripl
`
`30
`
`Server—Side ]avaScript Extensions Using LiveWire 747
`
`31 Partitioning Client and Server Applications
`
`775
`
`32 Database Connectivity Using LiveWire
`
`791
`
`Appendixes
`
`]avaScript Language Summary
`
`825
`
`Fundamentals of HTML 867
`
`Comparing ]avaScript with VBScript
`
`913
`
`]avaScript Resources on the Internet
`
`925
`
`Java from a]avaScripter’s Perspective
`
`933
`
`Index 959
`
`Google Exhibit 1018
`Page 7
`
`
`
`lnfroclucfion
`
`xxix
`
`Part I Gefling Siurled with Juvuscripi
`
`1
`
`.luvaScripf and the World Wide Web 3
`
`Introducing )avaScript ................................................................... .. 4
`Ten ]avaScript Facts Every Scripter Should Know .......................... .. 5
`]avaScript Is Embedded into HTML ......................................... .. 5
`JavaScript Is Browser—Dependent ............................................... .. 7
`JavaScript Is an Interpreted Language ........................................ .. 9
`]avaScript Is a Loosely Typed Language ..................................... .. 9
`]avaScript Is an Object—Based Language ................................... .. 10
`]avaScript Is Event—Driven ....................................................... .. 10
`]avaScript Is Not Java .............................................................. .. 10
`]avaScript Is Multifunctional ................................................... .. 1 1
`]avaScript Is Evolving .............................................................. .. 11
`The ]avaScript Language Spans Contexts ................................. .. 12
`The Four Phases of the World Wide Web .................................... .. 12
`
`Phase I: Character—Based Hypertext ......................................... .. 12
`Phase II: Graphical—Based Static HTML Documents ............... .. 12
`Phase III: Dynamic HTML Documents .................................. .. 13
`Phase IV: Active HTML Documents ....................................... .. 13
`The Web Application Framework ................................................ .. 14
`Client Side ............................................................................... .. 15
`Server Side ............................................................................... .. 21
`
`..... .. 23
`What Can You Do with JavaScript? .....................................
`Client—Side Applications .......................................................... .. 24
`“Smart Frame” Support ........................................................... .. 24
`Data Validation ....................................................................... .. 25
`
`Creating Interactive Forms ...................................................... .. 25
`Client—Side Lookup Tables ...................................................... .. 27
`State Maintenance ................................................................... .. 27
`
`27
`Working with Java Applets, ActiveX Controls, and Plug—Ins
`Browser Support for JavaScript ..................................................... .. 28
`Netscape Navigator .................................................................. .. 28
`Microsoft Internet Explorer ..................................................... .. 29
`Other Browsers ........................................................................ .. 29
`
`Summary ...................................................................................... .. 29
`
`Google Exhibit 1018
`Page 8
`
`
`
`viii
`
`]m2zz5crz'pt
`UNLEASHED
`
`31
`2 How Javascript and HTML Work Together
`Embedding ]avaScript in Your HTML ......................................... .. 32
`Language ................................................................................. .. 32
`Source ...................................................................................... .. 33
`
`Viewing ]avaScript Code .............................................................. .. 34
`Executing Scripts .......................................................................... .. 35
`Loading a Page ........................................................................ .. 35
`User Action ............................................................................. .. 37
`
`Accommodating Unsupported Browsers ...................................... .. 38
`Using Netscape HTIVIL Enhancements ........................................ .. 39
`An Overview of HTML 3.2 and Netscape Enhancements ....... .. 40
`Netscape Enhancements .......................................................... .. 40
`Frames ..................................................................................... .. 45
`Tables ...................................................................................... .. 48
`textarea ................................................................................. .. 48
`
`Creating a ]avaScript Script .......................................................... .. 49
`Writing the Script .................................................................... .. 49
`Running the Script .................................................................. .. 51
`Summary ...................................................................................... .. 51
`
`3 Assembling Your JavaScript Toolkit 53
`An Overview of Necessary Tools .................................................. .. 54
`]avaScript Editors ......................................................................... .. 54
`Text Editors ............................................................................. .. 54
`
`Text—Based HTML Editors ...................................................... .. 56
`
`]avaScript—Specific Editors ....................................................... .. 57
`HTML Editors ............................................................................. .. 58
`
`Text—Based HTML Editors ...................................................... .. 58
`
`Visual HTML Editors ............................................................. .. 58
`Web Browsers .............................................................................. .. 61
`
`The JavaScript Development Process ........................................... .. 62
`Server—Side ]avaScript Tools ......................................................... .. 63
`Netscape LiveWire ................................................................... .. 63
`Borland IntraBuilder ............................................................... .. 64
`
`Summary ...................................................................................... .. 65
`
`4 Using Acadia Infuse to Create JavaScript Scripts 67
`A Step—by—Step Guide to Infuse .................................................... .. 68
`Creating a New File ................................................................. .. 70
`Creating a Form ...................................................................... .. 71
`Adding Text and Select Elements ............................................ .. 72
`Responding to the User Event ................................................. .. 74
`Previewing the Script ............................................................... .. 79
`
`Google Exhibit 1018
`Page 9
`
`
`
`Content:
`
`.IX
`
`Reusing Code with Frequent Scripts ............................................ .. 82
`Inserting a Frequent Script into Your Source File .................... .. 82
`Adding a Frequent Script ......................................................... .. 83
`Deleting a Frequent Script ....................................................... .. 83
`Customizing File Templates ......................................................... .. 84
`Using Advanced Editor Options .................................................. .. 85
`Finding a Matching Brace ........................................................ .. 85
`Setting a Bookmark ................................................................. .. 85
`jumping to a Line Number ...................................................... .. 86
`Summary ...................................................................................... .. 86
`
`Part II The Javascripl language
`
`5 Fundamentals of the JavaScript Language
`
`89
`
`How ]avaScript Relates to CGI and Netscape 1’lug—Ins ................ .. 90
`CGI Programming .................................................................. .. 90
`Netscape Plug—Ins .................................................................... .. 91
`]avaScript ................................................................................ .. 91
`Embedding a Script in an HTML Document .............................. .. 92
`Events .......................................................................................... .. 92
`
`Basic Syntax Issues ....................................................................... .. 92
`Versions of}avaScript .............................................................. .. 94
`Tokens .................................................................................... .. 95
`
`Identifiers ................................................................................ .. 95
`
`.................................................................. .. 96
`Keywords ............
`Reserved Words ....................................................................... .. 96
`
`Literals ..................................................................................... .. 97
`
`Variables ................................................................................ .. 100
`
`Constants ................................................................................... .. 106
`
`User—Defined Constants ........................................................ .. 106
`
`Colors ........................................................................................ .. 107
`
`Data Types ................................................................................. .. 111
`Expressions ................................................................................. .. 1 1 1
`Comments ................................................................................. .. 11 1
`
`1 13
`Operators ................................................................................... ..
`Functions ................................................................................... .. 113
`
`Summary .................................................................................... ..
`
`1 15
`
`1 17
`6 Operators
`Assignment Operators ................................................................ .. 119
`Arithmetic Operators ................................................................. .. 119
`Comparison Operators ............................................................... .. 122
`Comparison Operators in JavaScript 1.2 .......
`...................... .. 123
`
`Google Exhibit 1018
`Page 10
`
`
`
`]az1a5cript
`UNLEASHED
`
`String Operators ......................................................................... .; 125
`Conditional Operators ............................................................... .. 126
`Boolean Operators ..................................................................... .. 127
`The typeof Operator ................................................................. .. 127
`Function Operators .................................................................... .. 128
`Data Structure Operators ........................................................... .. 128
`Bitwise Operators ....................................................................... .. 129
`Bitwise Logical Operators ...................................................... .. 130
`Bitwise Shift Operators .......................................................... .. 131
`Why Mess with Bits? ............................................................. .. 132
`Operator Precedence .................................................................. .. 135
`Summary .................................................................................... .. 137
`
`7 Control Structures and Looping
`Conditional Statements .............................................................. .. 140
`If .......................................................................................... .. 140
`
`139
`
`If...Else ............................................................................. ..143
`Looping Statements .................................................................... .. 145
`for ........................................................................................ .. 145
`for...in ............................................................................... .. 148
`
`while ..................................................................................... ..149
`
`do. . .while ............................................................................ .. 150
`
`break and continue ............................................................. .. 151
`
`labeled ...................................................................................... .. 152
`
`with ........................................................................................... ..154
`
`switch ........................................................................................ .. 155
`
`Summary .................................................................................... .. 156
`159
`8 Functions
`
`Understanding Functions ........................................................... .. 160
`Creating Functions ..................................................................... .. 160
`\X/here to Declare Functions ....................................................... .. 161
`Inside the <HEAD> Section ...................................................... .. 161
`Calling Functions ....................................................................... .. 162
`Working with Arguments ........................................................... .. 162
`Varying the Number of Arguments ............................................ .. 166
`Using Global and Local Variables ............................................... .. 169
`Passing Objects by Reference ................................................. .. 171
`I Reusing Functions ...................................................................... .. 173
`Recursive Functions ................................................................... .. 173
`Summary .................................................................................... .. 174
`
`Google Exhibit 1018
`Page 11
`
`
`
`Part III
`
`Javascripf Oluieds
`
`179
`9 The JavaScript Object Model
`Talking the “Object Talk” .......................................................... .. 180
`Objects .................................................................................. .. 1 81
`Encapsulation ........................................................................ .. 186
`Messages ................................................................................ .. 187
`Classes ................................................................................... .. 188
`
`Is ]avaScript an Object—Oriented Language? ............................... .. 191
`Objects and Dot Notation ......................................................... .. 192
`Properties ................................................................................... .. 192
`Methods ..................................................................................... .. 193
`
`Events .....................................................
`
`................................ .. 196
`
`Exploring the ]avaScript Object Model ...................................... .. 198
`Containership in ]avaSctipt ........................................................ .. 199
`An Overview of]avaScript Objects ............................................. .. 200
`Navigator Objects .................................................................. .. 200
`Built—In Language Objects ..................................................... .. 211
`Summary .................................................................................... .. 21 5
`
`10 Handling Events 217
`
`Understanding Events and Event Handlers ................................ .. 218
`]avaScript Event Handlers .......................................................... .. 218
`Clicking an Object (onclick) ................................................ .. 221
`Submitting a Form (onsubmit) .............................................. .. 224
`Resetting a Form (onReset) ................................................... .. 225
`Modifying Data (onchange) ................................................... .. 226
`Receiving Focus (onFocus) ..................................................... .. 226
`Losing Focus (onBlur) ........................................................... .. 229
`Selecting Text (onselect) ...................................................... .. 230
`Moving the Mouse Over Objects
`(onMouseOver‘ and onMouse0ut) ........................................... .. 230
`Loading a Document (onLoad) .............................................. .. 235
`Exiting a Document (onunload) ............................................ .. 236
`Handling Errors (onErr‘or*) ......................................................... .. 237
`Aborting an Image Load (onAbor‘t) ............................................ .. 238
`Changing Event Handlers .......................................................... .. 238
`Triggering Events in Code ......................................................... .. 239
`Timer Events .............................................................................. .. 240
`
`Summary .................................................................................... .. 242
`
`Google Exhibit 1018
`Page 12
`
`
`
`]zzmSrri]2t
`U NLEASHED
`
`11
`
`Navigator Objects 243
`The Window Object .................................................................. .. 244
`Opening and Closing W’indows ............................................. .. 245
`Navigating Between Windows ............................................... .. 253
`Displaying Message Boxes ..................................................... .. 256
`Working with Status Bar Messages ........................................ .. 264
`The Frame Object ...................................................................... .. 266
`Creating Frames .................................................................... .. 268
`Adding ]avaScript Code to Frames ........................................ .. 273
`Synchronizing Frames ............................................................ .. 275
`Updating Frames ................................................................... .. 279
`Scripting Image Map Frames ................................................. .. 284
`Working with Frame URLs ................................................... .. 287
`Referencing Windows and Frames ............................................. .. 288
`The Current Window ............................................................ .. 288
`
`Parent to Child ...................................................................... .. 289
`
`Child to Parent ...................................................................... .. 290
`
`Child to Child ....................................................................... .. 293
`
`The Top Window ................................................................. .. 295
`The Location Object .................................................................. .. 299
`Opening a New URL ............................................................ .. 300
`VV/orking with the protocol Property .................................... .. 302
`The History Object .................................................................... .. 303
`Determining the Size of the List ............................................ .. 303
`Navigating the History List .................................................... .. 304
`The Navigator Object ................................................................ .. 307
`Summary .................................................................................... .. 310
`311
`
`‘I2 Document Objects
`The Document Object ............................................................... .. 312
`Creating HTML Documents Programmatically .................... .. 313
`Clearing a \Y/indow’s Contents .............................................. .. 317
`Changing Document Attribute Colors ................................... .. 320
`The Link Object ........................................................................ .. 326
`Referencing Link Objects ...................................................... .. 327
`Executing ]avaScript Code Using Links ................................. .. 329
`The Anchor Object .................................................................... .. 333
`The Image Object ....................................................................... . 334
`Instantiating an Image Object ............................................... .. 334
`Summary .................................................................................... .. 335
`
`Google Exhibit 1018
`Page 13
`
`
`
`‘I3 Form Objects 337
`The Form Object ....................................................................... .. 338
`Submitting Forms to the Server ............................................. .. 339
`Checking Elements on a Form ............................................... .. 341
`The Text Object ........................................................................ .. 343
`Assigning a Default Value to a Text Object ........................... .. 344
`Selecting Text Upon Focus .................................................... .. 346
`The Textarea Object .............................................................. .. 347
`Wrapping Text in a Textarea Object ..................................... .. 348
`The Button Objects: Submit, Reset, and Button ........................ .. 349
`The Checkbox Object ................................................................ .. 351
`Determining \Whether a Checkbox Object Is Checked .......... .. 352
`The Radio Object ...................................................................... .. 353
`Determining the Value of the Selected Radio Button ............ .. 354
`The Select Object ....................................................................... .. 356
`Creating a Selection List ........................................................ .. 356
`Creating a Scrolling List ........................................................ .. 358
`Creating a Multiselection List ................................................ .. 359
`Determining the Value or Text of the Selected Option .......... .. 359
`Determining the Values of Multiselection Lists ..................... .. 360
`Selecting an Option Using ]avaScript .................................... .. 362
`The Password Object ................................................................. .. 363
`The Hidden Object .................................................................... .. 363
`Summary .................................................................................... .. 366
`
`‘I4 Built-In Language Objects 369
`The String Object ...................................................................... .. 370
`Creating a String Object ........................................................ .. 370
`Working with Strings ............................................................ .. 371
`Formatting Strings ................................................................. .. 375
`Working with Special Characters ........................................... .. 383
`Converting Strings to Numbers ............................................. .. 385
`Converting Numbers to Strings ............................................. .. 385
`The Array Object ....................................................................... .. 386
`Creating an Array Object ....................................................... .. 388
`Working with Multidimensional Arrays ................................ .. 392
`The Date Object ........................................................................ .. 392
`Creating a Date Object .......................................................... .. 394
`\Working with Date Values .................................................... .. 395
`Working with Time Zones .................................................... .. 397
`Calculating with Dates .......................................................... .. 397
`
`Google Exhibit 1018
`Page 14
`
`
`
`jczwzbkript
`UNLEASHED
`
`The Math Object ....................................................................... .. 398
`The Boolean Object (]avaScripr 1.1 and Higher) ....................... .. 399
`The Number Object (]aVaScript 1.1 and Higher) ....................... .. 400
`The Function Object (]avaScript 1.1 and Higher) ...................... .. 402
`Summary .................................................................................... .. 402
`
`15 Creating Custom .lavaScript Objects 403
`
`Creating an Object ..................................................................... .. 404
`lnstantiating Objects .................................................................. .. 408
`Working with Object Instances .................................................. .. 409
`Creating Complex Objects ......................................................... .. 413
`Dynamic Creation of Objects ..................................................... .. 417
`Extending instantiated Objects .................................................. .. 420
`lndexing Object Properties ......................................................... .. 421
`Summary .................................................................................... .. 421
`
`Part IV Visual Programming Techniques
`
`16 Creating Special Effects with JavaScript 425
`
`Scrolling Marquees ..................................................................... .. 426
`Billboards ................................................................................... .. 429
`
`Color Fading .............................................................................. .. 437
`Animated Pushbuttons ............................................................... .. 439
`
`Summary .................................................................................... .. 444
`
`17 Controlling Layers with JavaScript 445
`Accessing Layers Using ]avaScript .............................................. .. 446
`Managing Overlying Layers ...............