Copyright ©1996, Que Corporation. All rights reserved. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 West 103rd Street, Indianapolis, IN 46290 or at support@mcp.com.

Notice: This material is excerpted from Special Edition Using JavaScript, ISBN: 0-7897-0789-6. The electronic version of this material has not been through the final proof reading stage that the book goes through before being published in printed form. Some errors may exist here that are corrected before the book is published. This material is provided "as is" without any warranty of any kind.


Introduction

Five years ago the Internet was mostly the province of academics and programmers, and the World Wide Web was an obscure idea in the minds of a few researchers. Today both are experiencing explosive growth and unparalleled interest. Web pages are being created at an astonishing rate. The fundamental challenge of Web page development is that while it is easy to create a Web page, it is more difficult to create an attractive and exciting one.

HTML, the markup language that describes the appearance of a page, is easy to learn, and requires no background in programming. HTML has undergone several revisions in order to meet the expanding needs of Web page authors. However, there are limits to what can be achieved inside HTML. The Java programming language was introduced to dramatically extend the Web developer's set of tools, but is still more complex than HTML. Java is very easy to learn; however, like most programming languages,it isn't easy to master. JavaScript bridges this gap.

JavaScript offers the Web page author a new level of sophistication without requiring him to become a programmer. JavaScript brings dynamic and powerful capabilities to Web pages, yet JavaScript is no more difficult to learn than HTML. JavaScript can be used to solve common problems, such as validating forms input, and can also be used to create dramatic and visually appealing content, which would be impossible with HTML. The goal of this book is to completely explore JavaScript, from the mundane to the extraordinary. It is designed as an introduction, a reference, and a continuous source of ideas, so that you may continually improve the Web pages that you create.

Who Should Use This Book?

JavaScript is a very new language-even newer than Java. Despite its newness it has attracted great attention because of its expressive power. This book is directed to anyone who wishes to master that power in order to create more attractive, dynamic and interesting Web pages.

No programming knowledge is required to benefit from this book, but some knowledge of HTML and Web page authoring is assumed. No prior experience with JavaScript is required, either. This book is designed to be inclusive, and provide information to all JavaScript users, from complete beginners to established experts. If you create Web pages and wish to enliven and enhance them, this book adds JavaScript to your toolbox. If you have already learned JavaScript and wish to go further and break through to complete mastery, this book gives you the information to do so.

How This Book Is Organized

The organization of this book is based upon a modular approach to learning JavaScript. The intent is to provide material suitable for all levels of knowledge, from the complete beginner to the advanced JavaScript programmer. To this end the book has five sections.

Part I, "JavaScript the Language," introduces the JavaScript language. The complete syntax and semantics of the language are thoroughly described, with particular attention paid to the close correspondence between HTML elements and JavaScript objects. Chapter 1, "What Is JavaScript?" discusses JavaScript's overall role in the development of Web pages. Chapter 2, "JavaScript: The Language," gives the syntax of JavaScript. This leads directly into a description of the relationship between events on a Web page and JavaScript, in Chapter 3, "Events and JavaScript." This is followed by an introduction to the all important topic of JavaScript objects in Chapter 4, "JavaScript Objects."

Part II, "JavaScript Objects," is a greatly expanded presentation of the JavaScript object model that begins in chapter 4 of part I. JavaScript objects can be classified as built-in objects or HTML objects. Built-in objects are thoroughly described in Chapter 5, "Built-In JavaScript Objects," while chapters 6 through 8 focus on HTML objects. Validation of HTML forms is the subject of chapter 6; each form element is also a JavaScript object. Navigation objects, such as links and anchors, are then described in chapter 7, while chapter 8 presents the top-level objects associated with the Web browser itself. Part II concludes with a thorough treatment of user-defined objects in chapter 9.

One of the tremendous advantages of a scripting language, such as JavaScript, is its ability to integrate diverse technologies on a single Web page. Part III is devoted to examining such technologies. Chapter 10 deals with plug-ins, which are becoming increasingly abundant and useful on the World Wide Web. The Java programming language has received massive attention, and is quite similar to JavaScript in structure. Chapter 11 provides a thorough introduction to Java, while Chapter 12 focuses on the critical topic of Web page animation using Java. Finally, Chapter 13 presents the Visual Basic Scripting language in brief, and also looks at its plug-in technology, OLE controls.

Part IV brings the user the most advanced material available on creating special effects using JavaScript. Controlling Web page appearance, producing spectacular visual effects, and fine-tuning user interaction are each the subject of an in-depth treatment in chapters 14 through 16. Each chapter contains at least one fully worked example that can be used immediately. JavaScript server technology is reviewed in Chapter 17>, while various development tools for JavaScript are covered in Chapter 18. Part IV concludes with an in-depth look at Web page development using the innovative Frames technology in Chapter 19.

The fifth part of this book is devoted to Learning from the Pros. This part contains advanced solutions to common, yet difficult problems. Several innovative techniques are described here, as well as pointers on how to enliven any JavaScript Web page. Chapters 20 through 22 describe site outlines in JavaScript, conversion from standard HTML to Frames, and a JavaScript online order system.

The book concludes with a series of reference appendices which summarize critical information presented in the main body of the text. A glossary of common JavaScript terms is given, along with a capsule description of all major JavaScript resources. A language summary is provided, as well as a list of known bugs in the current implementation of JavaScript (version 2.0.1). Future enhancements are also discussed in brief.

How to Use This Book

If you are completely new to JavaScript then you should begin with a thorough study of the introductory language materials of part I. This should be followed by the more thorough treatment of JavaScript objects in part II. From that point on any chapter or section can be consulted, based on your own particular interest. It should be noted that later chapters are generally more advanced than earlier ones, however.

If you are already familiar with JavaScript then you are encouraged to explore this book in a goal-oriented manner. The alternate technologies discussed in part III may well be new to you, even if you an experienced Web professional. Finally, parts IV and V should have something new and informative for everyone, as they are intended to stretch the limits of JavaScript technology.

Conventions Used in This Book

Que has more than a decade of experience writing and developing the most successful computer books available. With that experience, we've learned what special features help readers the most. Look for these special features throughout the book to enhance your learning experience.

The following font conventions are used in this book to help make reading it easier.

Tip:

Tips present short advice on a quick or often overlooked procedure. These include shortcuts.

Note:

Notes present interesting or useful information that isn't necessarily essential to the discussion. A note provides additional information that may help you avoid problems or offers advice that relates to the topic.

Caution:

Cautions look like this and warn you about potential problems that a procedure may cause, unexpected results, or mistakes to avoid.


QUE Home Page

For technical support for our books and software contact support@mcp.com

Copyright ©1996, Que Corporation