Instant Javascript


Build interactive Web pages with JavaScript using this unique sourcebook of ready-to-run scripts. Filled with over 90 scripts inside the book and on the accompanying CD, you'll be able to create a wide range of applications-from displaying banners and other Web graphics to using forms and building frames-and much more. In addition, you'll get detailed hands-on information for customizing and extending scripts for use in different environments. This guide also includes coverage of DHTML, plugins, security issues ...
See more details below
Other sellers (Paperback)
  • All (14) from $1.99   
  • New (5) from $39.99   
  • Used (9) from $1.99   
Sending request ...


Build interactive Web pages with JavaScript using this unique sourcebook of ready-to-run scripts. Filled with over 90 scripts inside the book and on the accompanying CD, you'll be able to create a wide range of applications-from displaying banners and other Web graphics to using forms and building frames-and much more. In addition, you'll get detailed hands-on information for customizing and extending scripts for use in different environments. This guide also includes coverage of DHTML, plugins, security issues and creation of e-commerce applications-plus, easy to identify icons throughout the text highlight what's on the CD, for quick reference.
Read More Show Less

Product Details

  • ISBN-13: 9780072129946
  • Publisher: McGraw-Hill Companies, The
  • Publication date: 3/8/2001
  • Pages: 740
  • Product dimensions: 1.45 (w) x 7.50 (h) x 9.25 (d)

Meet the Author

Martin Webb is a Java Technical Consultant for a large telecommunications company it the UK. He is the founder of, a successful non-profit Web site devoted to the discussion of Internet-related technologies (particularly JavaScript).

Michel Plungjan has been in computing full-time since 1986 and since 1995 his work has been concentrated on Inter/intranet technologies, including JavaScript, (D)HTML. Java. CGI, XML, and XSL. He also maintains the Q&A area of

Keith Drakard is a principal coder for a leading Web development company in the UK where he ties ColdFusion and PHP functionality to SQL databases and builds templates for easily maintainable Web sites. He is also an editor at, managing and writing the Games section.

Read More Show Less

Table of Contents

Ch. 1 JavaScript Overview 1
Ch. 2 Maths and Numbers 23
Ch. 3 Strings and Regular Expressions 69
Ch. 4 Arrays and Objects 121
Ch. 5 Location and Links 175
Ch. 6 Windows and Frames 239
Ch. 7 Date and Time 305
Ch. 8 Forms 385
Ch. 9 Images 443
Ch. 10 Cookies 501
Ch. 11 Dynamic HTML 531
Ch. 12 Applications 577
Ch. 13 Utilities 633
Ch. 14 Fun Stuff 659
Index 695
Read More Show Less


This book is loosely divided into two parts. The first part is primarily concerned with the different components in JavaScript, from basic mathematical expressions to the use of cookies to store persistent state between pages. Each chapter in this section explores in detail the possibilities surrounding the components, showing by way of practical, everyday, reusable example applications how to make use of the components. Chapters in this section include:

Chapter 2-Maths and Numbers

This chapter describes two calculators written in JavaScript, a standard calculator, and a scientific calculator. Shows how to use a random number generator to display random quotes. Includes several number utility functions that are reused many times throughout the remainder of the book.

Chapter 3-Strings and Regular Expressions

This chapter shows how to find and replace strings within other strings, along with a practical demonstration with a copyright boilerplate. It also shows how to create scrolling text links, how to manipulate a contacts list, and how to manipulate strings to apply Gourad shading. This chapter describes how to parse text strings, and finally how to use Regular Expressions to validate form data input.

Chapter 4-Arrays and Objects

This chapter shows how to hold data as objects and how to hold objects within arrays, to show how to visit one of many web sites in an automated tour. It also explores how to search data held in a database, along with a multiple-choice test, and finally how to sort an array of objects.

Chapter 5-Location and Links

This chapter describes how to interact with the current location to provide automatic redirection to a new location, shows how to automate previous and next buttons between different pages, and automate links between portions of the same page, describes how JavaScript can be used to manage a ring of related web-sites. It shows how to extract the browsers preferred language and loads an appropriately written web page. There's also information on how to password protect resources and verify the entered password, and finally how to write a JavaScript link crawler to crawl through all the links in a connected set of pages.

Chapter 6-Windows and Frames

This chapter shows how to target the entries in a select form list to various windows in a frame set. It describes how to read the entries in a directory listing and describes a tool to generate your own popup windows. The use of popup windows in a dictionary lookup is also illustrated, along with the use of frames to hold data between page views to provide a family tree application. The chapter addresses how popup windows can be used to debug your own applications, followed by a popup date selector application, and finally code to stop other sites framing your own pages, while at the same time provide a means to ensure your pages are correctly framed within their own frame set.

Chapter 7-Date and Time

This chapter explores how to work with and manipulate the current date and time. It shows how to extract the day of the week for any date, how to validate an input date, and display a different page based on the time of day. It describes how to show a yearly calendar, how to count forwards and backwards to different dates, how to calculate an age in years, months and days, and shows how to work with the zodiac and Chinese calendars. The chapter includes applications to show events, religious celebrations and birthdays associated with a date, and finally shows how to work out the current time anywhere around the world.

Chapter 8-Form

This chapter first shows how HTML forms and JavaScript can interact and includes applications to show how to send email forms, how to interact with drop down menus, and how to pass data from one form to another. It covers how to provide a generic and dynamic thank you page following a form submission and includes applications to pass data from one form to another by way of cookies and emails. It describes how to disable form fields in HTML 4, and includes a technique to control form data entry. It also covers how to filter data input, and how to generate a new form component to spin date values up and down through a list, and finally shows how to provide a generic sales order form to calculate the sub-totals and total along with any necessary taxes.

Chapter 9-Images

This chapter covers the ubiquitous highlighting of images, and a fast implementation of image rollovers, with a variation that fades the images in and out. It demonstrates how to use image maps with applications that show an image slide show, and bar chart generation. It also shows how to count the number of images downloaded, popup windows to hold images, including an image counter, random banner adverts, and an image toolbar.

Chapter 10-Cookies

This chapter addresses general-purpose cookies functions for saving, retrieving and deleting cookies, and shows how to combine cookies with HTML to mark items as new. Intelligent cookies that avoid continual writing of cookies when disabled within the browser are also covered. The chapter's cookie tracker application demonstrates how cookies can be used to track a visitor's movement around a web site, and the personal calendar application shows how cookies can be used to store personalization information.

The second part of the book builds on the first part to generate far more complex applications, and at the same time build a cross-browser code library to support Dynamic HTML techniques in both Netscape Navigator (versions 4 and 6) and Internet Explorer (versions 4 and 5). Chapters in this section include:

Chapter 11-Dynamic HTML

This chapter describes the Document Object Model, including those available in Internet Explorer 5 and Netscape Navigator 6. Builds a crossbrowser compatible library for manipulating the DOM. It demonstrates the use of a cross-browser library to collapse content, dynamically change the cascading style sheet used to display the page, display tool tips that float above the document, handle multi-dialog forms, and toolbar menus with drop-down content. The library is also used to automatically generate a table of contents from the heading tags within a document, to slide tabbed content from the sides of the document, along with a hierarchical menu structure that can be opened and closed to show different leafs within a tree structure. The final application demonstrates a dynamic advert that interacts with the user.

Chapter 12-Applications

This chapter shows fully fledged applications, including two versions of a shopping cart application, one using simple hypertext links and form buttons to interact with the user, and the second using drag n' drop techniques. The application shows how the user can personalize their view of your page. The computer builder/selector demonstrates how different complex views of several products can be generated from a simple database of products and components. The book catalog applications show how JavaScript can interact with an XML document the DOM and style sheets all within one application.

Chapter 13-Utilities

Various uses of JavaScript are covered in this chapter. The color picker allows you, the author, to experiment with mixing background and foreground colors. The onscreen keyboard shows how users can interact with the page even when a keyboard isn't present. The automated scrolling application demonstrates how the page can be scrolled automatically without user intervention. The homepage script can be used to select the current page as the users default homepage. The final application shows how to detect for support of plugins and ActiveX components, both of which extend the basic browser beyond what it is capable of.

Chapter 14-Fun Stuff

The final chapter covers the more fun aspects of JavaScript, including three JavaScript games-from the simple icon match game to the more interesting JavaScript versions of Tetris and Columns. The amusing mouse trail application shows how interesting DHTML techniques can be used to follow the mouse pointer around the screen, while the final application of the book, the personality test, can be used to rate the user's personality, or lack thereof.

All of the examples in this book are exactly that: examples. Examples that can be adapted to your needs, or perhaps provide inspiration of what JavaScript is capable o£ Rather than a dry, and perhaps dull reference book on JavaScript, this book instead illustrates JavaScript applications, nearly 100 in total, that can be used as they stand or built on to provide even more complex and interesting programs.

Accompanying CD-ROM

All the example code, including the applications, is included on the accompanying CD-ROM, as denoted by the CD-ROM icon. There should be no need to type in the code by hand. If, however, you decide to do this you should first check the code on the CD-ROM before reporting any problems with your code.

If you do have problems with the code on the CD-ROM then you can report these along with any errors or omissions in the book, or any suggestions for improvements in future editions of the book, to Martin Webb at Any updates or errata found after the book has gone to print will be detailed online at the supporting web page at

As the book progresses less and less of the code is presented in the book. This is to first highlight the most important aspects of the code, and secondly to reduce the size of the overall book. However, the accompanying CD-ROM includes all the code for all the applications in full. The first few chapters of the book do however include all the necessary JavaScript code and HTML markup.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)