Online Documentation Server
 ÏÎÈÑÊ
ods.com.ua Web
 ÊÀÒÅÃÎÐÈÈ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ÏÎÄÏÈÑÊÀ

 Î ÊÎÏÈÐÀÉÒÀÕ
Âñÿ ïðåäîñòàâëåííàÿ íà ýòîì ñåðâåðå èíôîðìàöèÿ ñîáðàíà íàìè èç ðàçíûõ èñòî÷íèêîâ. Åñëè Âàì êàæåòñÿ, ÷òî ïóáëèêàöèÿ êàêèõ-òî äîêóìåíòîâ íàðóøàåò ÷üè-ëèáî àâòîðñêèå ïðàâà, ñîîáùèòå íàì îá ýòîì.




Previous Table of Contents Next

What is JavaScript?

JavaScript is an easy-to-use object scripting language designed for creating live online applications that link together objects and resources on both clients and servers. While Java is used by programmers to create new objects and applets, JavaScript is designed for use by HTML page authors and enterprise application developers to dynamically script the behavior of objects running on either the client or the server. JavaScript’s design and concepts represent the next generation of software for the Internet and is:

  • designed for creating network-centric applications
  • complementary to and integrated with Java
  • complementary to and integrated with HTML
  • open and cross-platform

With JavaScript, an HTML page might contain a form that processes data on the client side. A server-side JavaScript might pull data out of a relational database and format it in HTML on the fly. A page might contain JavaScript scripts that run on both the client and the server.

Who Can Benefit from JavaScript?

Generally speaking, Web surfers benefit most from JavaScript, because they have the opportunity to enjoy the language’s capabilities in the form of games, animation, interaction, and so forth. But not only the common Web surfer can benefit from the language. Netscape Communications obviously benefits from JavaScript, because it gives them a competitive advantage over other Web browsers, especially Microsoft Internet Explorer, which is still in the process of catching up with Netscape Navigator’s JavaScript implementation.

Many other companies believe that they will benefit from JavaScript and its descendants. The words of Rose Ann Giordano, vice president of the Internet Business Group at Digital Equipment Corp., demonstrate it:

Tools like JavaScript will unleash a new wave of creativity and transform the Internet in ways no one can predict. JavaScript and other developments will demand increased system performance, ideally met by Digital’s Alpha systems architecture.

Jan Silverman at Hewlett-Packard also mentioned how JavaScript matches his company’s plans in a press release:

JavaScript is an exciting technology because it represents the next generation of software designed specifically for the Internet. Hewlett-Packard is committed to open standards and is a supporter of JavaScript because it complements Hewlett-Packard’s open systems architecture.

The History of JavaScript

JavaScript was originated by Netscape as LiveScript, developed in parallel with LiveWire server software. LiveScript was developed for several applications—we’ll discuss two of them here. The first one is to enhance Web pages in a way that HTML cannot. The classic example is verifying a user’s form entries. Instead of sending the data as is to the server and validating the data types there, the client handles all the validation and only then sends the data to the server for further processing. Another application for LiveScript (JavaScript) is the communication glue between HTML documents and Java applets. A scrolling banner, for example, can use information from the user’s customized settings, sent to the applet by LiveScript. This data exchange is transparent to the server and, since there is no server-client communications, there is no response time penalty.

In December 1995, Sun Microsystems took over LiveScript development and changed its name to JavaScript. On the one hand, JavaScript is related to Java in its C++ object flavor. On the other hand, JavaScript’s vernacular is much reduced compared to Java, in order to make it suitable for less experienced programmers and scripters. JavaScript’s first and foremost advantage is in its ease of learning. Only then comes its features and capabilities which are important for Web page interactivity as well as for customizing solutions around prewritten applets.

In 1996 Microsoft introduced its first JavaScript-enabled browser, Internet Explorer 3.0. Netscape followed up a week later with another JavaScript-enabled browser, Netscape Navigator. Internet Explorer was far from reaching Navigator 3.0’s level in terms of JavaScript and lacked many important features and capabilities. In early 1997 the beta version of Netscape Navigator version 4.0 (Communicator) was released. Microsoft Internet Explorer was still far from reaching Navigator 3.0’s level.

JavaScript in a Browser

Client-side JavaScript

Client-side JavaScript is the most common form of the language. The script should be included in or referenced by an HTML document for the code to be interpreted by the browser. Suppose you load a Web page with a JavaScript-generated banner. The browser begins interpreting the HTML code and then encounters a JavaScript script. If the script has no syntax errors, it is executed by the browser’s built-in interpreter.

The JavaScript client-side mechanism features many advantages over traditional CGI server-side scripts. For example, you might use JavaScript to check if the user has entered a valid e-mail address in a form field. The JavaScript function is executed when the user submits the form, and only if the entry is a valid e-mail address (includes an @) is the form transmitted to the server for further processing, database storage, and so on. In this case, the user does not need to wait until the form is submitted over the network to the server and back to the client, only to be informed that a single character is missing.

Browser Objects

JavaScript is an object-based programming language. Its built-in object model is mostly based on the HTML content of the given Web page. The tight interaction between JavaScript and other browser objects (such as forms, browser windows, frames, and images) provides full control over various page elements and enables the programmer to create a link between “external” objects and “internal” ones. A classic example for such linking is a JavaScript script that invokes a Java applet from an HTML form.

JavaScript exposes objects and properties related to the browser’s window, history list, status bar, frames, forms, links, and so forth. Furthermore, JavaScript can be used to trap user-initiated events such as button clicks, link navigation, and other actions that the user explicitly or implicitly initiates. You can create a distinct script for each event, enabling a smooth, logical interaction with the user.

Previous Table of Contents Next


With any suggestions or questions please feel free to contact us