1.1 What JavaScript Is


JavaScript is a popular general-purpose scripting language used to put energy and pizzaz into otherwise dead Web pages by allowing a static page to interact with users and respond to events that occur on the page. JavaScript has been described as the glue that holds Web pages together. [1] It would be a hard task to find a commercial Web page, or almost any Web page, that does not contain some JavaScript code (see Figure 1.1).

[1] But the creator of JavaScript, Brendan Eich, says it's even more! In his article, "Innovators of the Net: Brendan Eich and JavaScript," he says, "Calling JavaScript 'the glue that holds web pages together' is short and easy to use, but doesn't do justice to what's going on. Glue sets and hardens, but JavaScript is more dynamic than glue. It can create a reaction and make things keep going, like a catalyst."

Figure 1.1. A dynamic Web page using JavaScript to give it life. For example, if the user rolls his mouse over any of the links or items in the navigation bars, those items will change color .

graphics/01fig01.jpg

JavaScript, originally called LiveScript, was developed by Brendan Eich at Netscape in 1995 and was shipped with Netscape Navigator 2.0 beta releases. JavaScript is a scripting language that gives life, hence LiveScript, to otherwise static HTML pages. It runs on most platforms and is hardware independent. JavaScript is built directly into the browser (although not restricted to browsers), Netscape and Microsoft Internet Explorer being the most common browsers. In syntax, JavaScript is similar to C, Perl, and Java; e.g., if statements and while and for loops , are almost identical. Like Perl, it is an object-oriented, interpreted language, not a compiled language.

Because JavaScript is associated with a browser, it is tightly integrated with HTML. While HTML is handled by its own networking library and graphics renderer, JavaScript programs are executed by a JavaScript interpreter normally built right into the browser. When the browser requests such a page, the server sends the full content of the document, including HTML and JavaScript statements, over the network to the client. When the page loads, HTML content is read and rendered line by line until a JavaScript opening tag is read, at which time the JavaScript interpreter takes over. When the closing JavaScript tag is reached, the HTML processing continues.

JavaScript handled by a browser is called client-side JavaScript. Although JavaScript is used mainly as a client-side scripting language, it can also be used in contexts other than a Web browser. Netscape created server-side JavaScript to be programmed as a CGI language, such as Perl or ASP, but this book will address JavaScript as it is most commonly used ”running on the client side.



JavaScript by Example
JavaScript by Example (2nd Edition)
ISBN: 0137054890
EAN: 2147483647
Year: 2003
Pages: 150
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net