HTML and CSS Reference
In-Depth Information
1
Introduction to JavaScript
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 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).
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 a client-side language
designed to work in the browser on your computer, not the server. It is built directly into
the browser (although not restricted to browsers), Microsoft Internet Explorer and
Mozilla Firefox being the most common browsers. In syntax, JavaScript is similar to C,
Perl, and Java; for example, if statements and while and for loops are almost identical.
Like Perl, it is an interpreted language, not a compiled language.
Because JavaScript is associated with a browser, it is tightly integrated with HTML.
Whereas HTML is handled in the browser by its own networking library and graphics
renderer, JavaScript programs are executed by a JavaScript interpreter built 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.
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.”
1
 
 
 
Search WWH ::




Custom Search