Chapter 8: What is Scripting?
A script is a program that is embedded in a Web page. It is kept separate
from the page's
HTML by special tags, as we'll see soon. The script code is
executed when certain events occur, such as the page loading into a
browser or the user clicking an element on the page. A script can perform
a wide variety of actions, such as mathematical calculations, processing
text data, displaying messages to the user, controlling the browser, and
changing the appearance of the page. There are also some things scripts
cannot do, such as read files on your hard drive or access your systems
memory. These limitations are intentional, and were put in place for
security reasons. Without access to files and memory, it is essentially
impossible for a script to cause any mischief on the user's computer.
People would be very hesitant to visit Web pages with scripts if they
faced the possibility of malicious or unintentional damage to their system
and files.
The scripts that are the subject of this chapter are called client-side scripts
because they are downloaded as part of a Web page and executed on the
client's computer. You'll also hear about server-side scripts that are
executed remotely on the Web server, but that's a different topic.
Essentially every Web browser in use today includes support for scripts.
By far the most popular scripting language is JavaScript, and that's what
I'll be using in this chapter. Another commonly used scripting language is
VBScript, a Microsoft creation that is intended to have certain syntax
similarities with the Visual Basic programming language. If you already
know Visual Basic, you might find VBScript a bit easier to learn. For
most people, however, I recommend JavaScript.
A scripting language would not be able to do much on its own. It must
work in conjunction with the Document Object Model, our next topic.