HTML and CSS Reference
In-Depth Information
types must be declared. JavaScript types such as variables, parameters, and function
return types do not have to be declared. Java programs are compiled. JavaScript pro-
grams are interpreted by a JavaScript engine that lives in the browser.
JavaScript is not HTML, but JavaScript code can be embedded in an HTML docu-
ment and is contained within HTML tags. JavaScript has its own syntax rules and
expects statements to be written in a certain way. JavaScript doesn't understand
HTML, but it can contain HTML content within its statements. All of this will become
clear as we proceed.
JavaScript is not used to read or write the files on client machines with the exception
of writing to cookies (see Chapter 16, “Cookies”). It does not let you write to or store
files on the server. It does not open or close windows already opened by other applica-
tions and it cannot read from an opened Web page that came from another server.
JavaScript is object based but not strictly object oriented because it does not support
the traditional mechanism for inheritance and classes found in object-oriented program-
ming languages, such as Java and C++. The terms private, protected, and public do not
apply to JavaScript methods as with Java and C++.
JavaScript is not the only language that can be embedded in an application. VBScript,
for example, developed by Microsoft, is similar to JavaScript, but is embedded in Micro-
soft's Internet Explorer.
1.3 What JavaScript Is Used For
JavaScript programs are used to detect and react to user-initiated events, such as a
mouse going over a link or graphic. They can improve a Web site with navigational
aids, scrolling messages and rollovers, dialog boxes, dynamic images, and so forth.
JavaScript lets you control the appearance of the page as the document is being parsed.
Without any network transmission, it lets you validate what the user has entered into
a form before submitting the form to the server. It can test to see if the user has plug-
ins and send the user to another site to get the plug-ins if needed. It has string func-
tions and supports regular expressions to check for valid e-mail addresses, Social
Security numbers, credit card data, and the like. JavaScript serves as a programming
language. Its core language describes such basic constructs as variables and data types,
control loops, if/else statements, switch statements, functions, and objects. 4 It is used
for arithmetic calculations, manipulates the date and time, and works with arrays,
strings, and objects. It handles user-initiated events, sets timers, and changes content
and style on the fly. JavaScript also reads and writes cookie values, and dynamically
creates HTML based on the cookie value.
3. The JavaScript interpreter is normally embedded in a Web browser, but is not restricted to the browser.
Servers and other applications can also use the JavaScript interpreter.
4. The latest version of the core JavaScript language is JavaScript 1.8.1, supported by Mozilla and Microsoft
Internet Explorer.
 
 
Search WWH ::




Custom Search