HTML and CSS Reference
In-Depth Information
14.1 Overview of JavaScript
There are a variety of methods for adding interactivity to a Web page. As you learned
in Chapter 7, CSS can be used to achieve a hover effect as you position your mouse
pointer over a hypertext link. In Chapter 11 you saw examples of how Adobe Flash
can be used to add interactivity and animation to a Web page. As also described in
Chapter 11, JavaScript can be used to add interactivity and functionality to Web pages.
It's not a question of using either JavaScript or one of these other technologies. You can
use the strengths of each technology, and use JavaScript in addition to CSS, Flash, Java
applets, or any number of other technologies.
So, what is JavaScript? It's an object-based client-side scripting language interpreted by
a Web browser. JavaScript is considered to be object-based because it's used to work
with the objects associated with a Web page document : the browser window, the docu-
ment itself, and the elements such as forms, images, and links. Since JavaScript is inter-
preted by a browser, it is considered to be a client-side scripting language. A scripting
language is a type of programming language, but no need to worry! You don't have to
be a computer programmer to understand this.
Let's review clients and servers. In Chapter 10 we discussed hosting a Web site on a
Web server. As you learned, a Web host provider stores your Web site and allows you to
transfer your files to the Web server. Visitors to your site (also called users) are able to
point their Web browsers to your Web site using the URL provided by your Web host
provider. As you may recall, the user's Web browser is called a client.
JavaScript is interpreted by the client. This means that the JavaScript code, embedded
in the XHTML document, will be rendered by the Web browser. The server's job is to send
the XHTML document. The Web browser's job is to interpret the code in the XHTML
file and display the Web page accordingly. Since all the processing is performed by the
client (in this case, the Web browser), this is referred to as client-side processing . There
are programming languages that are executed on the server, and these are referred to as
server-side programming languages. Server-side processing may involve sending e-mail,
storing items in a database, or tracking items in a shopping cart. In Chapter 9 you
learned how to set the action of a form to point to a server-side script.
So, JavaScript is an object-based client-side scripting language interpreted by a Web
browser. The JavaScript code is embedded in the XHTML file and the Web browser
interprets it and displays the results as needed.
14.2 The Development of JavaScript
There is a popular misconception that Java and JavaScript are the same. Java and
JavaScript are completely separate languages with very little in common. As noted in
Chapter 11, Java is an object-oriented programming language. Java is robust, very tech-
nical, and can be used to build large applications for businesses, such as inventory con-
trol systems and payroll systems. Sun Microsystems developed Java in the 1990s and
designed the language to run on an operating system such as Windows or Unix. The
developers of Java also wanted the flexibility and popularity that would be available if
their language could run in a Web browser. Independently, the team at Netscape was
Search WWH ::

Custom Search