HTML and CSS Reference
In-Depth Information
EXPLANATION
1
The JavaScript
<script>
tag's
src
attribute is assigned the name of a file (name must
end in
.js
) that contains JavaScript code. The file's name is
welcome.js
and it con-
tains a JavaScript program of its own containing a simple JavaScript function that
will be called when the user clicks the “Welcome Me!” button. See Figure 1.15.
2
The JavaScript program ends here.
3
This is an HTML button input device. When the user clicks the button, a Java-
Script function called
welcome()
will be called. It is defined in the external file,
welcome.js
.
Figure 1.15
After clicking the “Welcome Me!” button, a function from the external
.js file is called.
As you can see in Figure 1.16, Pearson Education uses many external JavaScript files
(.js) files to produce their Web site.
Figure 1.16
Viewing the source code for a Web site using external JavaScript files.