HTML and CSS Reference
In-Depth Information
Why Would You Want to Use JavaScript?
JavaScript was initially introduced with Netscape Navigator 2.0 in 1996. Prior to the
introduction of JavaScript, the browser was an application that presented documents gen-
erated by a server or stored in files. With JavaScript, the browser became a platform that
could run programs. With JavaScript, these programs are included as part of web pages.
JavaScript is useful because it's deeply integrated with the browser. This integration
allows programmers to manipulate various aspects of the browser behavior, as well as
objects included on an Hypertext Markup Language (HTML) page. JavaScript uses
what's referred to as an event-driven model of execution. When you embed JavaScript
code in a web page, it isn't run until the event it's associated with is triggered.
The types of events that can call JavaScript include loading the page, leaving the page,
interacting with a form element in some way, or clicking a link. Plenty of other events
are available, too. Many of these events are utilized in what most users would consider to
be annoying ways. For example, many sites open an additional window containing an
advertisement when you navigate to one of their pages. This is accomplished using
JavaScript and the page load event. Other sites open additional windows when you leave
them; this is also accomplished using JavaScript triggered by an event. Less annoying
applications include validating forms before they are submitted, or displaying extra infor-
mation on a page when a user clicks a link without requiring a full page refresh.
NOTE
This introduction will by necessity be briskly paced. There are
many books written about JavaScript. The goal of these lessons is
to introduce you to JavaScript, enable you to get started accom-
plishing tasks, and hopefully kindle your interest to dig into the
language more deeply.
JavaScript enables you to manipulate web pages without sending a request back to the
server or to send a request to the server to retrieve information without leaving the page
that the user is on. Using these capabilities, you can change the contents of a page,
change the style of elements on a page, validate user input before a user submits a form,
and modify the behavior of the browser—all by using scripts embedded within your web
pages. Let's look at some of the advantages of using JavaScript to enhance your web pages.
Ease of Use
JavaScript is a real programming language and is regularly used to build large, complex
applications, including some you've probably seen, like Google Maps. At the same time,
compared to many other programming languages, it's easy to get started with JavaScript.
 
 
Search WWH ::




Custom Search