As statements and functions using the SCRIPT tag.
As event handlers using HTML tags.
The SCRIPT tag
A script embedded in HTML with the SCRIPT tag uses the format:
The optional LANGUAGE attribute specifies the scripting language as
The HMTL tag, <SCRIPT>, and its closing counterpart, </SCRIPT>
Example 1: a simple script.
That's all, folks.
Example 1 page display.
Hello net. That's all folks.
Scripts can be placed inside comment fields to ensure that your
Defining and Calling Functions
Scripts placed within SCRIPT tags are evaluated after the page loads.
Functions are stored, but not executed. Functions are executed by
events in the page.
It's important to understand the difference between defining a
function and calling the function. Defining the function simply
names the function and specifies what to do when the function is
called. Calling the function actually performs the specified actions
with the indicated parameters.
Example 2: a script with a function and comments.
Example 2 page display.
The HEAD tag
Generally, you should define the functions for a page in the HEAD
portion of a document. Since the HEAD is loaded first, this practice
guarantees that functions are loaded before the user has a chance to
do anything that might call a function.
Example 3: a script with two functions.
Example 3 results.
Use single quotes (') to delimit string literals so that scripts can
distinguish the literal from attribute values enclosed in double
quotes. In the previous example, function bar contains the literal
'left' within a double-quoted attribute value. Here's another