Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Ajax and JavaScript

Essential JavaScript

Steven Holzner provides the necessary skills and techniques for his guided tour of JavaScript. He begins with a history of the language.
This chapter is from the book

This chapter is from the book

Welcome to the world of JavaScript. This book is your guided tour to that world, so have no worries—you've come to the right place. That world is large and expanding in unpredictable ways every minute, but we're going to become familiar with the lay of the land in detail here. And there's a lot of territory to cover, because JavaScript is getting into the most amazing places, and in the most amazing ways, these days.

You'll see JavaScript just about everywhere you go on the Internet; it's the language of the web. JavaScript is a powerful, compact scripting language that gets embedded right in web pages, and brings them to life. In this book, we're going to see all of JavaScript at work, from the basics to the most advanced; from mouse rollovers to dynamic HTML; from status bar manipulations to opening new browser windows on command; from working with the mouse and keyboard to handling HTML controls such as buttons, check boxes, and drop-down menus; from working with XML and XSLT to working with .NET; from using style sheets to setting cookies. JavaScript supports a dazzling variety of options for your web pages, and it's all coming up in this book. We're going to see it all at work—and everything is going to be illustrated with at least one example.

This first chapter is our foundation chapter, where we'll get the necessary skills and techniques down to begin our guided tour of the language. To put things into perspective, a good place to start is with a history of JavaScript.

JavaScript Through the Ages

JavaScript is a unique language—despite its name, which has caused a great deal of confusion, it is not directly related to Java. When JavaScript was first introduced, Java was dominant, and it must have seemed like a good idea to tie JavaScript to Java.

Things have shifted dramatically, however; JavaScript has become far more popular than Java for web use. Whereas Java has gone on to become a relatively complex, involved language, JavaScript has remained remarkably the same over the years—a lightweight, fast, and powerful language that is, quite simply, the programmer's favorite—it's by far the favorite language of the web.

It all began in Netscape Communications Corporation in 1995, when a developer named Brendan Eich, who they had just lured away from MicroUnity Systems Engineering, was given a new project to work on. The original idea was to make programming more accessible than it was becoming in Java, and to somehow make the Netscape Navigator's new Java support more open to non-Java programmers. Eich took a look around and decided that what was needed was a scripting language that was fast and easy to use. Unlike Java, which first has to be compiled into "bytecodes," JavaScript was to be embedded right in the web page itself, and downloaded with that page. And as Java itself has become more and more inaccessible, JavaScript's star just continues to rise.

Brendan Eich called his creation LiveScript, but it was renamed JavaScript. (In fact, many people consider the name change a big mistake.) Although developed by Netscape, Sun had the trademarks on Java, and the name JavaScript is actually a trademark of Sun Microsystems, Inc. The new language was announced in a Netscape and Sun joint press conference on December 4, 1995. They originally positioned it as a "complement" to Java and HTML, rather than a simple support language for Java.

However, JavaScript rapidly slipped out of Java's shadow. Programmers took to it at once, and although there were problems with bugs and later with security, JavaScript was a success. It became clear that, as Eich had realized, programming a web page in the browser made all kinds of things possible that couldn't be done if you needed to reload the page from the server. (In fact, the most popular, original use for JavaScript was to swap images when the mouse rolled over them, and that continues to be a very popular thing to do.)

Web programmers found JavaScript programming fun. To some extent, that meant that many programmers didn't take it seriously. Java was a serious language, and as time has gone on, it has become much more serious—serious, unfortunately, to the point of inaccessibility for much of its intended audience. JavaScript, originally a guilty pleasure for many, started to be accepted by thousands of programmers. As browsers became more powerful and could run scripts faster (eliminating screen flicker and other problems), programmers discovered that JavaScript was indeed a viable development tool. And all it took was a few lines of code to get things working, making buttons work, and setting cookies.

As JavaScript started making waves, Netscape's chief competitor, Microsoft, could no longer ignore it. It's interesting to speculate how things would have gone if JavaScript had been a public standard in those days, developed, say, by a neutral third party. But JavaScript was a product of Microsoft's direct competitor in this area, Netscape, so Microsoft decided to create its own version of JavaScript, which it called JScript.

The first official version of JScript was released on July 16, 1996, in Internet Explorer 3.0. From then on, there was both JavaScript and JScript, and the resulting split personality for the language between Netscape and Microsoft has had repercussions that echo down to today. The original JScript was much like a reduced version of JavaScript 1.1, however, and the differences confused programmers. At that point, Microsoft had created its own scripting language, VBScript, based on its popular Visual Basic language, and was hoping to successfully rival JavaScript. JavaScript was triumphant, however, and VBScript is a very distant second these days.

To bring their JScript support up to full JavaScript 1.1, Microsoft later released a second version of Internet Explorer 3.0. So started the cross-browser and cross-browser version problems that have made life harder for the JavaScript programmer ever since. Programmers started to find that although JScript looked just like JavaScript, some scripts would run in Netscape and not in Internet Explorer, and vice versa.

Hoping to stave off chaos, Netscape and Sun looked for a third party to standardize JavaScript, and turned to the European Computer Manufacturers Association (ECMA, Unfortunately for programmers, that standardization, which began in November 1996, has been a long time coming, and even longer to be adopted. You might expect the standardized language to be called JavaScript, or possibly JScript, but it's not called either—it's ECMAScript.

So now we actually have three standards: JavaScript, JScript, and ECMAScript. Although ECMAScript has brought some measure of coherence to the picture, both browsers also have gone their own ways. The result is that the Internet Explorer often has two ways of letting you do things (the JScript way and the ECMAScript way), and the Netscape Navigator has two ways of letting you do things (the JavaScript way and the ECMAScript way). A big problem was that ECMAScript standardized the core JavaScript language itself, but not all the resources available in browsers that you work with—and those resources make up a much larger field than the JavaScript language does by itself.

These browser resources are made up of browser objects (discussed later in this chapter). Each browser had its own set of objects, such as the document object, which enables you to work with the web page, and the window object, which enables you to work with the browser itself. A great deal of JavaScript programming is all about working with these objects; and if they're entirely different in the two browsers, it's easy to see that the same JavaScript-enabled web pages are going to have problems in one or the other browser—so much so that people today are still coding different scripts in the same web page for the two browsers.

The chaos raised by different sets of browser objects threatened both JavaScript and JScript, so Microsoft, Netscape, and many other corporations went to the World Wide Web Consortium (W3C, to bring some coherence to the objects browsers would make accessible to JavaScript. The original browser object set, before W3C started its work, became known as the Document Object Model (DOM) "level 0." The DOM level 1, which became an official W3C specification on October 1, 1998, standardized many aspects of the objects found in browsers, but left out many others. DOM level 2 was made a specification on November 13, 2000, and fills in many more details. However, both DOM models omit any discussion of many of the popular objects available in both browsers, which means that much of what we're going to do is try to reconcile programming issues between those browsers. Work on the DOM level 3, now in the working draft stage, has started.

The result of all this is that today, JavaScript is an amazingly powerful tool for web programmers, but it's still plagued by cross-browser issues. The current version of JavaScript in the Netscape Navigator is 1.5 (with 2.0 on the way), and the current JScript version is 5.6. With each new version, more power from other languages has been packed into JavaScript, borrowing from languages such as C++, Java, Perl, and even TCL.

Although the W3C DOM has brought some calm to the war between the browsers, it's also true that market share has dramatically shifted to Microsoft. It would be a shame if the only way JavaScript compatibility could finally be ensured were by the demise of one of the competitors, but it appears that might be happening. Nonetheless, we're going to work with both browsers in this book—in fact, if there's an incompatibility, I'll indicate not only which browser something applies to, but which versions of that browser. That's the only way to do it.

We'll take a look at cross-browser programming in more detail both in this chapter and in Chapter 4, "Handling the Browser Environment." The very fact that incompatibility issues exist indicates that both Netscape and Microsoft consider JavaScript very important. And despite the cross-browser problems, JavaScript continues to flourish. So, in just what kind of ways do people use JavaScript these days? I'll take an overview of the JavaScript world now.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive:

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020