JavaScript is a language for "programming" documents.
JavaScript is a programming language that operates on the elements, attributes, and properties of a web page.
JavaScript exists within a web page and is interpreted every time the document is loaded into a web browser.
The time is now .
Generally speaking, JavaScript is an object-oriented scripting language, having its roots in C++, Java, and Apple HyperTalk.
Object-oriented means that the objects of its attention (e.g. elements on a web page) can be simply referenced, along with their properties (e.g. attribute values ) and the functions that can operate on them.
Because JavaScript is a "scripting" language, it removes a lot of the complexity of programming by making many basic assumptions, and as a result it is simpler to learn than either C++ or Java (and still in active use, unlike Apple HyperTalk).
In most cases, JavaScript runs within web browsers, unlike PHP which runs on the web server.
In addition to providing interactivity, this "client-side" location allows many desireable activities e.g. testing of form inputs before they are sent to a server:
JavaScript has many limitations designed to protect users from surreptitious activities on the client computer; for example, it cannot:
While the core language of JavaScript is essentially the same for the various DHTML platforms (each OS/browser combination), there can be significant differences:
You must therefore be very careful when using JavaScript to maximize cross-platform compatibility.
Dreamweaver also has many ready-to-insert scripts, accessible through Dreamweaver > Window > Behaviors .
JavaScript at its core looks a lot like C++ or Java, but is generally simpler.
As previously noted, JavaScript may exist just about anywhere within a document, and is interpreted as it is loaded.
The bulk of JavaScript will appear within the head or body of the document,
enclosed within
<script>....</script> tag pairs.
JavaScript statements in the head will be available to all statements in the body:
JavaScript statements in the body will be executed in a particular sequence relative to the layout language:
Amherst College was founded years ago.
JavaScript also provides for user interaction such as mouse clicks on document elements such as buttons, as well typing in input fields.
Event handlers in HTML look like ordinary attribute="value" pairs.
A useful approach for organizing JavaScript code is to store commonly accessed snipits into JavaScript source or "library" files (with a .js extension) that can be loaded into a document with an HTML statement such as the following:
You may have noticed that a user can turn off JavaScript in browsers that understand it:


Since you can't control a user's settings, if they have turned JavaScript off you may wish to do some things differently or warn the user of limited functionality.
By putting document language between <noscript>....</noscript> tag pairs, a knowledgeable browser will only display them when JavaScript is turned off:
<script language="JavaScript">
|
|
document.write("This statement is designed to generate an error" |
javascript:in Navigator's location field, a JavaScript Console will open displaying information about any errors that have occurred since startup.
The console can also be used to type in JavaScript to test it.
Safari > Window > Activity
Operators
Controls
Arrays
Objects