Professional JavaScript | 17 | WebReference

Professional JavaScript | 17

1234
[next]

Professional JavaScript

A JavaScript interpreter can't do much in a vacuum; it needs to work with a host program. The host program supplies all the interesting objects, functions and data that the interpreter operates on. Through these things, scripts can read input from a user, display output to a user, and perform computations in between.

Mainstream Browsers and JavaScript

JavaScript has its origins in the Internet and the World Wide Web, so it's no surprise that Web browsers are the places JavaScript is most frequently used. In most cases, this is achieved by adding JavaScript scripts to documents that normally only contain HTML tags and content.

Of the many, many Web browsers available; Microsoft's Internet Explorer and Netscape's Navigator and Communicator have the lion's share of the market. JavaScript's impact on these mainstream browsers is considered the 'ordinary case' and we'll be looking at those browsers primarily. In this chapter we'll also briefly consider some of the less well known alternatives. Alas, unless their popularity improves, the lesser known browsers are likely to occupy only small niches in the browser marketplace.

Adding JavaScript to HTML

An HTML document that contains JavaScript can be looked at from two points of view. Looked at from the outside, as a mere textual document, there are only select places in an HTML document where JavaScript scripts can be added. Looked at from the inside as a collection of tags and content items, an HTML document consists of numerous interesting features that can be manipulated by any scripts that can get at those features. It is the former view that is described here.

Since JavaScript scripts can only be placed in HTML documents in certain spots, opportunities for acting upon the document or the browser displaying the document are limited. However, what JavaScript can do in an HTML document is:

Let's throw a little jargon in at this point. An HTML document may have JavaScript scripts embedded in it. The browser running these JavaScript/HTML pages hosts a JavaScript interpreter or has a JavaScript interpreter embedded in it.

1234
[next]
and
Created: February 12, 2001
Revised: March 5, 2001

URL: http://webreference.com/programming/javascript/professional/chap4/