Teach Yourself JavaScript in a Week ● Overview ● Acknowledgments ● About the Author ● Introduction Day 1 Chapter 1 Where Does JavaScript Fit In? ● Overview of Javascript and Navigator ● Strengths and Weaknesses of JavaScript Chapter 2 Your First Script ● Incorporating JavaScript into HTML ● Command Block structure in JavaScript ● Output functions From the Web: Dave Eisenberg's Calendar Day 2 Chapter 3 Working with Data and Information ● Data Types ● Using Variables ● Assignment Expressions ● Operators Chapter 4 Functions and Objects: The Building Blocks of Programs ● Defining Functions ● Creating new objects, properties and methods ● Using arrays From the Web: Ashley Cheng's Ideal Weight Calculator Day 3 Chapter 5 Events in JavaScript ● onLoad ● Click ● onChange, and more Chapter 6 Creating Interactive Forms ● The form object ● Working with form elements: button, checkbox, etc. From the Web: Michael Yu's Civic Car Viewer Day 4 Chapter7 Loops ● for in loop ● While loop ● break and continue statements Chapter 8 Frames, Documents, and Windows ● Working with frames ● Working with the status bar ● Controlling the timing of scripts From the Web: James Thiele's Reminder Calendar Day 5 Chapter 9 Remember Where You've Been with Cookies ● Cookies and CGI ● Using cookies in JavaScript ● The navigator object Chapter 10 Strings, Math, and the History List ● Manipulating the content of strings ● The Math object ● Building dynamic forward and back buttons From the Web: Michal Sramka's Matches Game Day 6 Chapter 11 Having Fun with JavaScript ● Build a face application ● Provide a random face button Chapter 12 Creating a Spreadsheet in JavaScript ● Build a Working Spreadsheet ● Save Expressions between sessions From the Web: CCAS Indirect Cost Worksheet Day 7 Chapter 13 Navigator Gold: A JavaScript Development Tool ● Developing JavaScript in Navigator Gold ● Features of Navigator Gold Chapter 14 From JavaScript to Java—Looking into the Future ● Basic Java concepts ● Incorporating Java applets in HTML ● The APPLET tag ● Similarities between JavaScript and Java Appendixes Appendix A JavaScript Reference Resources Appendix B JavaScript Language Reference Appendix C Glossary ● Teach Yourself JavaScript in a Week ■ Copyright © 1996 by Sams.net Publishing ❍ Overview ❍ Acknowledgments ❍ About the Author ❍ Introduction ■ Goal of this Book ■ Who Should Read this Book? ■ Web Authors and Designers ■ Others ■ Preparing to Begin ■ Where to Obtain Navigator 2.0 ■ Editing and Development Tools ■ Conventions in this Book Teach Yourself JavaScript in a Week Arman Danesh 201 West 103rd Street, Indianapolis, Indiana 46290 To my parents—Michele and Hossain—for instilling in me a thirst for knowledge, and to my wife—Tahirih—who inspires me to press forward. Copyright © 1996 by Sams.net Publishing FIRST 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 responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams.net Publishing, 201 W. 103rd St., Indianapolis, IN 46290. International Standard Book Number: 1-57521-073-8 Library of Congress Catalog Card Number: 95-72943 99—98—97—96————4—3—2—1 Interpretation of the printing code: the rightmost double-digit number is the year of the book's printing; the rightmost single-digit, the number of the book's printing. For example, a printing code of 96-1 shows that the first printing of the book occurred in 1996. Printed in the United States of America All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams.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. President, Sams Publishing: Richard K. Swadley Publishing Manager: Mark Taber Managing Editor: Cindy Morrow Marketing Manager John Pierce Assistant Marketing Manager: Kristina Perry Acquisitions Editor Mark Taber Development Editor Kelly Murdock Software Development Specialist Merle Newlon Production Editor Marla Reece Technical Reviewer Wes Tatters Editorial Coordinator Bill Whitmer Technical Edit Coordinator Lynette Quinn Formatter Frank Sinclair Editorial Assistants Carol Ackerman Andi Richter Rhonda Tinch-Mize Cover Designer Tim Amrhein Book Designer Gary Adair Copy Writer Peter Fuller Production Team Supervisor Brad Chinn Overview Introduction Day 1 1 Where Does JavaScript Fit In? 2 Your First Script Day 2 3 Working with Data and Information 4 Functions and Objects—The Building Blocks of Programs From the Web: Dave Eisenberg's Calendar Day 3 5 Events in JavaScript 6 Creating Interactive Forms From the Web: Ashley Cheng's Ideal Weight Calendar Day 4 7 Loops 8 Frames, Documents, and Windows From the Web: Michael Yu's Civic Car Viewer Day 5 9 Remember Where You've Been with Cookies From the Web: James Thiele's Reminder Calendar 10 Strings, Math, and the History List Day 6 11 Having Fun with JavaScript From the Web: Michal Sramka's Matches Game 12 Creating a Spreadsheet in JavaScript Day 7 13 Navigator Gold—A JavaScript Development Tool 14 From JavaScript to Java—Looking into the Future Appendixes A JavaScript Reference Resources B JavaScript Language Reference C Glossary Index Acknowledgments Writing this book has been a process that has involved many people. I particularly would like to thank the staff at Sams.net who worked with me in developing the manuscript: Kelly Murdock, Marla Reece, and Mark Taber and many others I am sure were involved. I would also like to thank Gautam Das at the Baha'i World Centre in Haifa, Israel, for reading sections of the book as I was writing it. About the Author Arman Danesh Arman Danesh works as the Web Development Specialist at the Baha'i World Centre in Haifa. He is also Editorial Director of Juxta Publishing Limited, based in Hong Kong. He received his Masters of Science in Mass Communication from Boston University in 1990. He has also worked as a technology journalist and is a regular contributor and Internet columnist for the South China Morning Post and The Dataphile. Arman lives with his wife, Tahirih, in Haifa, Israel. Introduction The World Wide Web has come a long way since its days as a modest hypertext system used by a few scientists to share information on the Internet. Today the World Wide Web is the medium of information exchange for millions of people. They are sharing text, video, sound, and data, and increasingly, they are trying to make their Web pages interactive. Businesses are trying to sell their products, artists are producing new forms of interactive art, and programmers are producing program development aids—all delivered via the World Wide Web and accessed from inside everyday Web browser applications. In many ways, we are in the midst of an information revolution with a move away from document- centric computing to a network-centric paradigm. Right at the center of this shift is Netscape Communications and its immensely popular Web browser, Netscape Navigator. By incorporating Java from Sun Microsystems and its own JavaScript scripting language into the current version of the Netscape Navigator browser, Netscape has helped generate a flurry of movement on the World Wide Web aimed at creating interactive documents and information. Java is a platform-independent programming language designed for distributed applications on the Internet. JavaScript presently enhances the functionality of the immensely popular Netscape Navigator Web browser, enabling Web authors and developers to produce content that changes in response to user actions—dynamic data that makes information more accessible and easier to organize and digest. In this book we are going to take a look at JavaScript—the internal scripting language Netscape has developed and included in the Navigator browser. JavaScript is an evolving tool, like so many tools associated with the Internet and the World Wide Web. Still, the future of JavaScript is sufficiently clear that many people have already developed sophisticated Web-based applications using the language. Goal of this Book As I mentioned in the Introduction, this book is designed to teach the JavaScript scripting language. We start by taking a broad look at Netscape Navigator 2.0, the current version of the popular Web browser, which some estimates say commands more than 80 percent of the Web browser market. Following this, we take an introductory look at JavaScript and its relationship with Java and its place in the Netscape suite of Web development tools. Once this is done, we will be ready to look at the nuts and bolts of the JavaScript language and learn how to apply them to real-world scenarios on the Web. JavaScript can be used to add a wide range of interactivity and functionality to Web pages including the following: ● Dynamic forms that include built-in error checking ● Spread sheets and calculators ● User interaction in the form of warning messages and confirmation messages ● Dynamic changes to text and background colors ● The ability to analyze URLs and access URLs in a user's history list ● The capability to open, name, clear, and close new windows and direct output to specific frames These types of functions already appear in numerous Web sites on the World Wide Web, and it is expected that the number will grow rapidly in early 1996 now that Navigator 2.0 has moved from being a beta product to commercial release software. Throughout the book, you will have the opportunity to develop several small scripts that you can immediately use in your own Web pages. Finally, we close with a review of the future of JavaScript and where it seems to be heading. We will consider Netscape's plans as well as announcements from other companies to include JavaScript in their products. Who Should Read this Book? The JavaScript scripting language naturally interests a diverse group of people, including Web designers and authors, programmers, and application developers. Web Authors and Designers This book is clearly of interest to Web developers and authors with experience using HTML and designing Web sites, including using Netscape extensions. Although basic knowledge of HTML is assumed throughout the book, any advanced or complicated HTML tags being used are introduced and described as needed. Naturally, programming knowledge and an understanding of the Common Gateway Interface (CGI)—used for adding interactivity at the server end—is helpful in any discussion of Web development. However, it is not essential for learning JavaScript, and readers with a sound knowledge of HTML tags can follow the lessons in this book. By the end of the book, not only will you be able to write simple (and complex) JavaScript programs, but you also will have learned to use some of the newer Netscape extensions to HTML. Others Naturally, discussion of a programming language like JavaScript is not solely of interest to Web authors and designers. Programmers looking to add the latest technology to their list of credits are increasingly interested in learning JavaScript. In addition, applications developers looking at Navigator 2.0 as an engine for deploying platform-independent graphical user interface applications will quickly find that JavaScript is going to play a critical role in implementing their applications. Preparing to Begin In order to take full advantage of this book, you will need several tools. A copy of the latest version of Netscape 2.0 is essential to develop and test program code. In addition, a good editing program that you will feel comfortable using will make the program development process easier. Where to Obtain Navigator 2.0 Today, JavaScript capabilities can only be found in Netscape's Navigator 2.0 Web browser. Navigator 2.0 moved from being beta software to actual release software in early 1996 In order to take full advantage of the lessons in this book, it is necessary to have access to a copy of Navigator 2.0 to try the examples and exercises for yourself. Navigator 2.0 is available for most computer platforms, including all versions of Windows, Mac OS, and a wide range of UNIX variants including Sun OS, Solaris, and Linux. At the present time, there is no native OS/2 version of Netscape Navigator available. If you need to download a copy of the current version of Navigator 2.0, you can get it from Netscape's home page at http://home.netscape.com/ or from Netscape's numerous FTP servers or their many mirrors: ftp://ftp.netscape.com/ ftp://ftp2.netscape.com/ ftp://ftp3.netscape.com/ ftp://ftp4.netscape.com/ ftp://ftp5.netscape.com/ ftp://ftp6.netscape.com/ ftp://ftp7.netscape.com/ ftp://ftp.leo.chubu.ac.jp/pub/WWW/netscape/ (Japan) ftp://sunsite.ust.hk/pub/WWW/netscape/ (Hong Kong) ftp://sunsite.huji.ac.il/Netscape/ (Israel) ftp://ftp.adelaide.edu.au/pub/WWW/Netscape/ (Australia) ftp://sunsite.doc.ic.ac.uk/computing/information-systems/www/Netscape/ (United Kingdom) ftp://ftp.informatik.rwth-aachen.de/pub/mirror/ftp.netscape.com/ (Germany) ftp://wuarchive.wustl.edu/packages/www/Netscape/ (U.S.A.) ftp://sunsite.unc.edu/pub/packages/infosystems/WWW/clients/Netscape (U.S.A.) Editing and Development Tools In addition to a copy of Navigator 2.0, a strong editor or development tool will make the task of entering, developing, and debugging JavaScript much easier. If you already do a lot of HTML authoring or programming, you probably have your own favorite tools that will be well-suited to JavaScript development. As long as your editing software produces plain ASCII text files, you should be just fine. However, several tools may make it easier to develop, edit, and trouble-shoot your JavaScript programs. In considering editors, it would be worth looking at tools that can help you identify the current line number for debugging scripts. In addition, the ability to launch Netscape Navigator from an editor is a useful feature already found in many HTML editors. Most HTML editors are suitable to JavaScript development, although a few—including leading products such as HoTMetaL—are designed to perform validation of HTML and can't be used to develop JavaScript scripts easily. In addition to a high quality text or programming editor, many users may want to consider Netscape's Navigator 2.0 Gold. Although Navigator Gold was only available in an early beta version (beta 1) when this book was written, Netscape has indicated that it will take the Navigator 2.0 browser and adds a suite of development and editing tools that make it easy for developers to produce interactive applications deployed on Netscape technology—all in a WYSIWYG (What You See Is What You Get) environment (or as close as is possible with the Web). More information about Navigator Gold is available from the site at http://home.netscape.com/comprod/products/navigator/version_2.0/gold.html. Conventions in this Book This book uses certain conventions to aid you, the reader, in your learning process. NewTerm A new term is highlighted in italics or with this icon to clarify its meaning. Note boxes highlight important or explanatory information in the surrounding text. These helpful nuggets offer insight or short cuts to programming puzzles. Pay special attention to warnings. They may just save your system! "Input" appears next to a listing that you should enter to follow along with the author's lesson. A listing without an Input icon is for illustration or explanation only. [ic:ccc]This arrow at the beginning of a line of code means that a single line of code requires multiple lines on the page. Many lines of code contain a large number of characters, which might normally wrap on your screen. However, printing limitations require a break when lines reach a maximum number of characters. Continue typing all characters after the [ic:ccc] as though they are part of the previous line. Besides on-screen output, "Output" is often used, in this book, to point to a figure that results from the preceding code listing. "Analysis" The author offers detailed explanations regarding the parts and purposes of the code. (Hint: If you think you might not understand what the code is meant to perform, skip to this section before you input the listings!) This book also uses monospaced fonts to denote terms, functions, keywords, variables, and so on, that are taken from or are part of the code. monospaced italics refers to a placeholder that should be filled in with the actual number, variable, or value represented. Typically, HTML code terms are in ALL CAPS, while JavaScript terms are in the case required by this case-sensitive language. ● Day 7 Day 7 13 Navigator Gold[md]A JavaScript Development Tool 14 From JavaScript to Java[md]Looking into the Future ● Day 6 Day 6 11 Having Fun with JavaScript From the Web: Michal Sramka's Matches Game 12 Creating a Spreadsheet in JavaScript From the Web: CCAS Indirect Cost Worksheet . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs11.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs12.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/07tjs01.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/07tjs02.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/07tjs03.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/07tjs04.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs01.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://wwww.juxta.com/juxta/docs/prod.htm: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs02.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs03.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs04.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs05.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.hidaho.com/frameset/: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs06.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs07.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs08.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs09.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/08tjs10.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.eskimo.com/%7ejet/javascript/calendar_js.html: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/09tjs07.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/09tjs08.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/09tjs01.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/09tjs02.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/09tjs03.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/09tjs04.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/09tjs05.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/09tjs06.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/10tjs01.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/10tjs02.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/10tjs03.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/10tjs04.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.sanet.sk/%7ems/js/matches.html: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/11tjs03.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/11tjs01.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/11tjs02.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/12tjs01.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/12tjs02.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/tjsifcfi.htm: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.ccas.com/ccasrate.html: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/12tjs04.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/12tjs05.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/12tjs06.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/12tjs07.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs01.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs02.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://home.netscape.com/eng/mozilla/Gold/handbook: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs03.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs04.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs05.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs06.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs07.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs08.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs09.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs10.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs11.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs12.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs13.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs14.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/13tjs15.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/tjsoffi.htm: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://home.netscape.com/comprod/products/navigator/version_2.0/script/index.html: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://home.netscape.com/eng/mozilla/Gold/handbook/javascript/index.html: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.c2.org/%7eandreww/javascript/: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.c2.org/%7eandreww/javascript/lib/: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.ipst.com/docs.htm: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.txdirect.net/users/everett/: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.jchelp.com/javahelp/javahelp.htm: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://ourworld.compuserve.com/homepages/vood/script.htm: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.gamelan.com/: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://java.sun.com/: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.center.nitech.ac.jp/ml/java-house/hypermail/0000: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.obscure.org/: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/tjsdy1fi.htm: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www1.mhv.net/%7ejamihall/java/GrowingText/GrowingText.html: This file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/14tjs01.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/14tjs02.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/14tjs03.gif: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/tjsdy6fi.htm: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/tjsdy2fi.htm: This file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/tjsdy5fi.htm: This file was not retrieved by Teleport Pro, because it is linked too far away from its Starting Address. If you increase the in-domain depth setting for the Starting Address, this file will be queued for retrieval. . http://www.mcp.com/850435200/1-57521/1-57521-073-8/tjsdy3fi.htm: This file was not retrieved by Teleport Pro, because it is linked too far away from its Starting Address. If you increase the in-domain depth setting for the Starting Address, this file will be queued for retrieval. - AlphaNumeric Listings - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AlphaNumeric Listings (-) unary negation * (asterisk) * (asterisk) in passwords * (multiplication operator) + (addition operator) + (concatenation operator) + (plus sign) ++ (increment operator) - (subtraction operator) (decrement operator) / (division operator) // (slashes) <A> tag = (assignment operator) = (equal sign) \ (backslash) { } (braces) - A - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AlphaNumeric Listings abs( ) method absolute URLs Acrobat Amber Reader ACTION attribute: FORM tag action property addition (+) operator addressing: object propreties by name addURL( ) function advanced features of Navigator Gold 2.0 alert boxes alert( ) method alignment: images ALINK attribute (BODY tag) anchor array: order of anchors anchors array anchors: empty angle( ) function APPLET tag: attributes applets: adding protocols to browsers applets: categories applets: displaying applets: Gamelan applets: GrowingText applets: HTML files applets: interaction applets: Java applets: Java applets: Java applets: live data feeds applets: parameters applets: parameters applets: scrolling text applets: stand-alone application requirements applications: GUI applications: JavaScript applications: JavaScript applications: stand-alone architecturej-neutral- byte-codes arguments arguments: characters arguments: open( ) method arguments: passing to functions arguments: replace( ) function arguments: substring( ) method arithmetic operators Array constructor object array object: declaring arrayOfDaysInMonth( ) function arrays: anchor arrays: anchors arrays: associative arrays: associative arrays: calendar month arrays: creating arrays: defining arrays: defining arrays: elements arrays: elements[ ] arrays: entries arrays: forms[ ] arrays: frames arrays: links array arrays: sites ASAP WebShow assigning: values to variables assignment expressions assignment operator (=) assignment operators (table) assignment operators: bitwise associative arrays associative arrays asterisk (*) asterisk (*) in passwords attributes: ACTION attributes: APPLET tag attributes: BACKGROUND attributes: BODY tag attributes: BODY tag attributes: BODY tag attributes: BODY tag attributes: BODY tag attributes: ENCTYPE attributes: FORM tag attributes: FRAME tag attributes: NAME attributes: SCRIPT tag attributes: Set-Cookie field attributes: TARGET attributes: TARGET attributes: VALUE - B - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AlphaNumeric Listings BACKGROUND attribute (BODY tag) background color background color background: color background: images backslash (\) banners: frames base 10 integers base 16 integers base 8 integers BASE tag: attributes bases: notation BGCOLOR attribute (BODY tag) binary operators bitwise assignment operators blank cells blocks: command blocks blur( ) method bmi( ) function Body Mass Index: calculating body of document BODY tag BODY tag BODY tag: attributes BODY tag: attributes BODY tag: attributes BODY tag: attributes BODY tag: attributes BODY tag: attributes BODY tag: document object body text: inserting boolean literals braces ({ }) break command break statement browser window browser window: changing to editor window browsers: Navigator 2.0 browsers: properties browsers: protocols browsers: scripts build.htm buildBoard( ) function buildFace( ) function buildForm( ) function building tables: dynamically building URLs built-in functions built-in methods: limitations built-in objects buttons buttons buttons: File/Edit toolbar (editor window) buttons: INPUT tag buttons: Let's See buttons: onClick event handler buttons: One Button Publish buttons: properties buttons: radio buttons: start buttons: submit bye( ) function byte codes bytecodes: verification - C - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AlphaNumeric Listings calculate( ) function calculate( ) function calculations: repeating calculator calculator: creating with tables calculators calendar month: array calendar( ) function calendar( ) function calling functions: passing variables/literals case methods case sensitivity case sensitivity: functions casting categories of applets cells (tables): building cells: table cells: tables CENTER tag centering: text centimeters CGI (Common Gateway Interface) CGI scripts CGI scripts: cookies character format toolbar (editor window) character format: applying characters: as arguments characters: escaping characters: special charAt( ) method check( ) function checkAnswer( ) function checkboxes checkboxes: if else statement checkboxes: methods checkboxes: properties checkform( ) function checkFormNum( ) function checking errors checking for numbers with loops checkNum( ) function checkNumber( ) function circle( ) function classes classes: copies classes: creating clear( ) method clearField( ) function ClearForm( ) function clearForm( ) function clearForm( ) functions clearing field values clearing forms: RESET button clearTimeout( ) method click( ) method client window: output to client window: text client/server: interaction client/server: interaction close( ) method closing windows code: hiding code: JavaScript color color color picker color tester: document object color words: RGB triplets color: background color: changing color: fonts color: foreground color: links color: links colors: saving as cookies columns: defining columns: numbering columns: setup columns: variable columns: variable come_on( ) function command blocks command blocks command blocks: writing commands: break commands: multiple commands: multiple lines commands: syntax commands: var commands: with comments: HTML Common Gateway Interface (CGI) comparing JavaScript and Java comparing: applets and HTML files comparison operators comparisons: if-else constructs compiled languages compiling source code computeField( ) function computeform( ) function computeForm( ) function concatenation concatenation (+) operator conditional expressions conditional loops conditional operators conditions conditions confirm boxes confirm( ) method constructor functions constructor objects: Array constructs: nested object construct continue statement control frame control.htm: source code converting between degrees and radians Cookie field Cookie field: request header cookie property: document object cookieFound variable cookies cookies: Bill Dortch's function set cookies: CGI scripts cookies: creating cookies: creating cookies: deleting cookies: encoding cookies: erasing cookies: examples cookies: expressions cookies: extending script value cookies: HTTP headers cookies: limitations cookies: sites cookies: updating cookies: user choice storage cookies: values copies: classes copying: array entries Corel Vector Graphics count field countdown application: dynamic HTML content createArray object createArray( ) function createArray( ) type function creating: arrays creating: calculator with tables creating: classes creating: cookies creating: cookies creating: expressions creating: expressions creating: files creating: files creating: formulas creating: HTML documents creating: links creating: objects creating: objects creating: variables - D - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AlphaNumeric Listings data types data types: literals data validity Date object: creating instances Date object: methods dates: writing in sequence dayClick( ) function daysInMonth( ) function debugging debugging: tools decimal integers: floating point literals decimals decimals declarations: functions declaring: array objects declaring: global variables declaring: objects declaring: variables declaring: variables declaring: variables decode( ) function decrement ( ) operator Default colors/Backgrounds screen defaultValue property defining arrays: numeric defining arrays: ordered set of elements defining: columns defining: document object defining: frameset defining: functions defining: functions defining: objects defining: properties defining: variables definitions: functions degrees/radians,converting DeleteCookie( ) function deleteExp( ) function deleteURL( ) function deleting: cookies deleting: expressions deleting: expressions development time development: tools diagonals, testing (tic-tac-toe) dialog boxes dialog boxes: document properties dialog boxes: horizontal line properties dialog boxes: image properties dialog boxes: Modify/Insert dialog boxes: outputting to dialog boxes: prompt( ) method display windows: dynamic output display: rows displaying: applets displaying: files displaying: files displaying: messages displaying: messages displaying: messages displaying: options displaying: welcome message distributed publishing division (/) operator document object document object: color tester document object: cookie property document object: defining document object: methods document object: properties document properties dialog box document window: opening document.cookie: assigning values document.write( ) method document.write( ) method document.write( ) method document.write( ) statement document.writeln( ) method document: top-level documentation: JavaScript documentation: JavaScript documents: body documents: hierarchical relationship documents: HTML documents: images documents: loading documents: opening drag-and-drop drop down menus drop down selection lists drop-down list: paragraph formats drop-down selection menus: building dynamic output dynamic output: display window - E - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AlphaNumeric Listings EarthTime editing environment editing: expressions editor window editor window: browser window editor window: character format toolbar editor window: description editor window: File/Edit toolbar editor window: opening editor window: paragraph format toolbar editor window: pop-up menus editor: setup efficiency improvements elements of arrays: referencing elements property elements: button elements: checkboxes elements: hidden elements: password elements: radio elements: reset elements: select elements: submit elements: text elements: textarea elements[ ] array embedding: command blocks embedding: FRAMESET containers embedding: if-else constructs empty anchors empty strings emulating events encode( ) function encoding cookies encoding property encoding: forms ENCTYPE attribute (FORM tag) environments: editing environments: WYSIWYG Envoy equal sign (=) erasing cookies error checking error checking: improvements escape( ) function escape( ) method escaping characters eval( ) method eval( ) statement evaluateExp( ) function event handlers event handlers: commands event handlers: form object event handlers: form tags event handlers: functions as event handlers: INPUT tag event handlers: invoking event handlers: names event handlers: onChange event handlers: onClick event handlers: onLoad event handlers: onMouseOver event handlers: onSubmit event handlers: onUnload event handlers: select object event methods events: basics events: emulating events: forms events: input focus events: user events examples: JavaScript Exec( ) function exp( ) method expressions expressions expressions: assignment expressions: checking number saved expressions: conditional expressions: conditional expressions: creating expressions: deleting expressions: deleting expressions: editing expressions: saving expressions: saving expressions: structure expressions: syntax expressions: update expression expressions: update form expressions: updating expressions: user created extensibility: JavaScript extensible object-oriented languages extracting: URLs extractSites( ) function eyes.htm - F - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AlphaNumeric Listings faces: building facial features: options facial features: selecting factorial( ) function factorials FGCOLOR attribute (BODY tag) fields fields: altering contents fields: amount fields: clearing fields: Cookie fields: count fields: extracting information fields: help text fields: hidden fields: Set-Cookie fields: Set-Cookie fields: text fields: titles fields: values fields: values FIGleaf Inline file extensions: js file headers: function definitions File/Edit toolbar (editor window) files: build.htm files: creating files: displaying files: eyes.htm files: formats files: frames files: HTML files: HTML files: htmlform.html files: image files: mouths.htm files: naming files: noses.htm files: saving files: viewing floating point values focus( ) method fontcolor( ) method fontcolor( ) method fonts fonts: color fonts: size fontsize( ) method for loop: building option list for loop: instead of calculate function for loops for loops: creating arrays for in loop foreground color form checking form events form object form object: event handlers form object: instances form object: methods form object: properties FORM tag: ACTION attribute FORM tag: attributes FORM tag: attributes form tags: event handlers formats: character formats: character formats: file formats formats: paragraph formats: paragraph forms: clearing forms: elements forms: encoding forms: expression update form forms: HTML forms: names forms: spreadsheet forms: verification forms[ ] array Formula One/NET formulas: Math object formulas: mathematical operators formulas: user created FRAME tag FRAME tag FRAME tag: attributes FRAME tag: attributes frames frames frames array frames property: window object frames: banners frames: control frames: files frames: introduction frames: loading frames: menus frames: names frames: nested frames: nesting frames: opening URLs frames: scroll bars frames: size frames: sizing frames: title frames: updating frames: URLs FRAMESET containers: nesting FRAMESET tag framesets: defining framesets: hIdaho framesets: nested framesets: nested framesets: parent framesets: parent framesets: top-level Fringe Benefit Rate function statements function table: registering functions functions: addURL( ) functions: angle( ) functions: arguments functions: arrayOfDaysInMonth( ) functions: as event handlers functions: basics functions: bmi( ) functions: buildBoard( ) functions: buildFace( ) functions: buildForm( ) functions: built-in functions: bye( ) functions: calculate( ) functions: calculate( ) functions: calendar( ) functions: calendar( ) functions: calling functions: case sensitivity functions: check( ) functions: checkAnswer( ) functions: checkform( ) functions: checkFormNum( ) functions: checkNum( ) functions: checkNumber( ) functions: circle( ) functions: clearField( ) functions: clearForm( ) functions: ClearForm( ) functions: clearForm( ) functions: come_on( ) functions: computeField( ) functions: computeform( ) functions: computeForm( ) functions: constructor functions: createArray( ) functions: createArray( ) type functions: dayClick( ) functions: daysInMonth( ) functions: declarations functions: decode( ) functions: defining functions: definitions functions: definitions functions: definitions functions: DeleteCookie( ) functions: deleteExp( ) functions: deleteURL( ) functions: encode( ) functions: escape( ) functions: evaluateExp( ) functions: Exec( ) functions: extractSites( ) functions: factorial( ) functions: getcar( ) functions: getCookie( ) functions: getCookieVal( ) functions: getExpression( ) functions: getRandom( ) functions: getURL( ) functions: greeting( ) functions: help( ) functions: hypotenuse functions: initialize( ) functions: intro( ) functions: isNum( ) functions: IsRegistered( ) functions: letsgo( ) functions: loadURL( ) functions: makeList( ) functions: names functions: newCookie( ) functions: newwindow( ) functions: parameters functions: parsing functions: play( ) functions: randomFace( ) functions: recursive functions: recursive functions: Register( ) functions: registering functions: replace( ) functions: returning results functions: saveExp( ) functions: search( ) functions: selectPage( ) functions: SetCookie( ) functions: side( ) functions: space( ) functions: startTest( ) functions: test( ) functions: triangle functions: unescape( ) functions: UnRegister( ) functions: UnRegisterFrame( ) functions: update( ) functions: urlList( ) functions: welcome( ) functions: win( ) [...]... HotJava Java: moving toward Java: security JavaHouse mailing list JavaScript JavaScript support JavaScript: code JavaScript: compared to Java JavaScript: development JavaScript: documentation JavaScript: extensibility JavaScript: future JavaScript: HTML files JavaScript: HTML relationship JavaScript: index JavaScript: library JavaScript: mailing list JavaScript: Navigator 2.0 relationship JavaScript: ... column: incrementing variable columns: column names variable scope variables variables variables variables: cookieFound variables: creating variables: declaring variables: declaring variables: defining variables: global variables: global variables: global variables: global variables: global variables: global variables: local variables: names variables: output variables: passing as arguments variables:... possible to cast a number into a string as in "Count to " + 10 evaluating to a string with the value "Count to 10" Creating Variables In order to make working with data types useful, you need ways to store values for later use This is where variables come in In JavaScript you can create variables that can contain any type of data Variables have names, and after assigning values to a variable, you can refer... capabilities include an applications programmer's interface (API) for plug-ins Plug-ins are program modules that dynamically extend the capability of Navigator 2.0 to handle new types of data and information, along with JavaScript and Java, which allow the addition of flexible progammability to Web pages In this chapter we also take a detailed look at the main features and aspects of JavaScript, as well as review... from the way in which information is handled in traditional procedural programming languages such as FORTRAN and C In these languages, information and procedures (similar to methods) are kept separate and distinct and are not linked in the way that objects are Also, the concept of creating instances isn't as well developed in procedural languages Working with Objects in JavaScript JavaScript includes... Point Values Floating point values can include a fractional component A floating point literal can include a decimal integer plus either a decimal point and a fraction expressed as another decimal number or an exponent indicator and a type suffix, as shown in the following examples: q 7.2945 q x34.2 q 2E3 Floating point literals must, at a minimum, include a decimal integer and either the decimal point... program code Extra spaces and tabs don't have any effect on JavaScript programs In JavaScript, object, property, and method names are case sensitive, as are all keywords, operators, and variable names You learn about operators and variables in Chapter 3, "Working with Data and Information." Case is only important in strings of text (otherwise known as string literals and discussed in Chapter 3) In this... recursion initial values initialize( ) function input focus INPUT tag: buttons INPUT tag: event handlers inserting: body text inserting: headings inserting: images in documents inserting: lines instances instances: form object integers integers: decimals integers: hexadecimals integers: octals interacting with user interaction between applets interactivity: Netscape InterCAP Inline interface: script interpreted... languages intro( ) function introduction to Navigator Gold 2.0 invoking: event handlers isNum( ) function IsRegistered( ) function iteration -JA B C D E F G H I J K L M N O P Q R S T U V W X Y Z AlphaNumeric Listings Java Java applets Java Home Page Java vs JavaScript Java: applets Java: applets Java: basic concepts Java: compared to JavaScript Java: ease of learning Java: extensibility Java: HotJava... to the value by name If you subsequently assign a new value to the variable, you can continue referring to that new value by the name of the variable Declaring Variables In order to use a variable, it is good programming style to declare it Declaring a variable tells JavaScript that a variable of a given name exists so that the JavaScript interpreter can understand references to that variable name throughout . concepts Java: compared to JavaScript Java: ease of learning Java: extensibility Java: HotJava Java: moving toward Java: security JavaHouse mailing list JavaScript JavaScript support JavaScript: code JavaScript: . associative arrays: associative arrays: calendar month arrays: creating arrays: defining arrays: defining arrays: elements arrays: elements[ ] arrays: entries arrays: forms[ ] arrays: frames arrays:. names variable scope variables variables variables variables: cookieFound variables: creating variables: declaring variables: declaring variables: defining variables: global variables: global variables: