01-12-2012, 04:12 PM
Advanced JavaScript Second Edition
Advanced Javascript.pdf (Size: 9.43 MB / Downloads: 137)
Introduction
Prerequisites
JavaScript is a scripting language designed to be used within HTML documents. For
this reason a basic working knowledge of HTML is required before you can learn or
use JavaScript. For those readers either lacking this basic knowledge or requiring a
refresher course,Chapter 2 is a basic HTML primer that will teach you all of the skills
you will need.
A Programming Refresher
Chapter 3 is a brief crash course in basic JavaScript to help readers with no prior
knowledge of JavaScript as well as those who require a brief refresher. This chapter
covers all the fundamental elements of JavaScript and will prepare the reader to continue
on with the material in this book.
How to Read This Book
As the title suggests,this book is geared towards advanced JavaScript programming
and has the experienced JavaScript programmer in mind. However,the first few chapters
do provide basic primers on both HTML and JavaScript. Those with limited
JavaScript experience should carefully study the first few chapters,while more experienced
programmers may want to skim these chapters or skip them entirely.
The Structure of This Book
It’s important to understand how the book is structured so you can plan your learning
experience in the best possible way. The table of contents lists the chapters by name.
If you are an experienced JavaScript programmer just looking for a reference on a particular
subject,feel free to skip directly to the relevant chapter.
JavaScript is a viable scripting language for both Netscape and Internet Explorer,so I
will use examples from both browsers and will point out any differences. If you have
the latest version of either Netscape or Internet Explorer,then virtually all the examples should work fine for you. Older versions of both browsers,par ticularly 3.0
and earlier,lack ed support for some JavaScript features.
Programming Style
As both an aid to the reader and to illustrate good programming practices,I use a uniform
style throughout this entire text and in all the sample code you will find on the
companion CD. For example,all variables are in Hungarian notation,meaning the variable
is preceded by one to three letters designating the type of variable it is. For
example,an integer being used as a loop counter might be named intcounter,and a
float that holds an account balance might be named fltbalance. I also have a tendency
to comment very heavily,some would say too much. This comes from
Introduction to JavaScript
The World Wide Web
It may be hard for some readers to recall a time when the web was not a part of our
day-to-day lives. However, it was not until the early ’90s that the web became a serious
medium for communication. Prior to that, the major uses of the Internet were
simply e-mail and file transfer. This is not to say that web pages did not exist before
then; it’s simply that they were not a widespread communication tool. By the early
21st century, however, there were millions of web sites from major corporations and
government agencies to 10-year-olds putting up web sites extolling the virtues of
their favorite cartoon. It is hard to imagine conducting business today without some
web presence, whether it’s a small web site that gives the essentials of your business
or a full blown e-commerce site.
This spread of the web has also lead to greater expectations from web pages. Originally,
simply putting up some well-organized text was enough to give you a
successful web site. But soon, web surfers became accustomed to graphics, animations,
sounds, and more. All of this could be accomplished with successive versions of
HTML. Modern web users, however, expect a higher level of functionality from web
sites.
Competition on the Web
Site popularity is usually measured by the number of visits, or “hits,” a web site
receives. Major sites such as www.yahoo.com can receive tens of thousands of hits per
day. Less popular sites may only receive a few hundred hits a day, while personal web
pages may only receive a few hits per week or month. The competition to get visitors
to sites is becomingquite fierce. In fact, advertisingdollars are now pouringin to sites
that can attract a significant number of visitors. The most common way to get visitors
to a site is to add content, both informational/functional and purely decorative. This is
an area for which JavaScript is ideally suited.