Execution of JavaScript
Credit: J. Trauger (JPL/NASA)
There are 5 ways of including JavaScript code in your HTML files:
- You can embed it between <SCRIPT> and </SCRIPT> tags.
See
this for an example.
This is the usual method.
- A second common method is to include JavaScript code as
an event handler inside HTML elements in Forms. Typically,
the JavaScript code is very small and is usually a call to
a function which may carry out complex tasks. See
this for the output of a
simple example.
- A third, less usual, method, is to use
<SCRIPT SRC=...> tags to read in JavaScript source
from a file. This is one way to (partially) get around the
limitation that Client-Side JavaScript cannot read data from
the server -- you can embed data as a JavaScript program.
However, the data is in an extremely limited format and
would usually be limited to a few hundred values.
See this
for an example near the end of this file.
- There exist two other methods that are sometimes used:
(a) using a special
Javascript: URL protocol,
and (b) embedding code with the JavaScript HTML entity, but
we will not discuss them here.
|
 |
 |
 |

Class Topics
Client-Side JavaScript
JavaScript as a Programming Language
Execution of JavaScript
"JavaScript" Document Object Model
Programming with JavaScript
Using Cookies in JavaScript
Using JavaScript to Write HTML
JavaScript and DHTML
JavaScript and CGI
Homework Assignments
|