|
|||
|
Click Here! |
Teach YourselfJavaScript 1.1 in a WeekSecond Editionby Arman DaneshC O N T E N T SIntroduction
Chapter 1 Where Does JavaScript Fit In?
Chapter 2 Your First Script
Chapter 3 Working with Data and Information
Chapter 4 Functions and Objects-The Building Blocks of Programs
Chapter 5 Events in JavaScript
Chapter 6 Creating Interactive Forms
Chapter 7 Loops
Chapter 8 Frames, Documents, and Windows
Chapter 9 Remember Where You've Been with Cookies
Chapter 10 Strings, Math, and the History List
Chapter 11 Having Fun with JavaScript
Chapter 12 Creating a Spreadsheet in JavaScript
Chapter 13 Navigator Gold-A JavaScript Development Tool
Chapter 14 From JavaScript to Java-Looking into the Future
appendix A JavaScript Reference Resourcesappendix B JavaScript Language Reference
appendix C Glossaryappendix D What's on the CD-ROM
Credits
Copyright © 1996 by Sams.net Publishing SECOND EDITIONAll 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-195-5
HTML conversion by :
Trademarks
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. JavaScript is a
trademark of Sun Microsystems, Inc.
AcknowledgmentsWriting 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 Bahá'í World Centre in Haifa, Israel, for reading sections of the book as I was writing it. About the AuthorArman Danesh Arman Danesh works as the Web Development Specialist at the Bahá'í 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. Arman may be reached via e-mail at [email protected]. Tell Us What You Think!As a reader, you are the most important critic and commentator of our books. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. You can help us make strong books that meet your needs and give you the computer guidance you require.
Do you have access to CompuServe or the World Wide Web? Then check
out our CompuServe forum by typing GO
SAMS at any prompt. If you prefer the World
Wide Web, check out our site at http://www.mcp.com.
As the team leader of the group that created this book, I welcome
your comments. You can fax, e-mail, or write me directly to let
me know what you did or didn't like about this book-as well as
what we can do to make our books stronger. Here's the information:
IntroductionThe 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 BookAs 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 3.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:
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 as JavaScript develops maturity as a programming language. 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 DesignersThis 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. OthersNaturally, 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 BeginIn order to take full advantage of this book, you will need several tools. A copy of the latest version of Netscape 2.0 or 3.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 3.0In order to take full advantage of the lessons in this book, it is necessary to have access to a copy of Navigator 3.0 to try the examples and exercises for yourself. Navigator 3.0 is available for most computer platforms, including all versions of Windows, MacOS, 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 3.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/ Editing and Development ToolsIn addition to a copy of Navigator 3.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 Conventions in this Book
This book uses certain conventions to aid you, the reader, in
your learning process.
This icon 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.
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 as though they are part of the previous line.
Besides on-screen output, this icon is often used, in this book, to point to a figure that results from the preceding code listing.
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.
|
Use of this site is subject certain Terms & Conditions. Copyright (c) 1996-1999 EarthWeb, Inc.. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Please read our privacy policy for details. |