Lesson 9 Notes
Lesson 9 Notes
Since Lesson 1, you have expanded your knowledge of HTML codes through a series of HTML practice exercises. These
exercises, used in conjunction with the assignments, culminated in a complete Web site.
This final practice exercise will introduce you to a programming language that can make your Web pages more powerful.
That programming language (a scripting language) is known as JavaScript. This exercise is NOT a requirement of the final
Web project but may be used if you desire. Concepts from this exercise MAY be used on the final exam.
Please note, JavaScript is much different than the programming language known as Java.
What is JavaScript?
· Object-based scripting language
· Works with the objects associated with a Web page document
o the window
o the document
o the elements
What is JavaScript?
· Originally developed by Netscape
o Named LiveScript
Coding JavaScript
· JavaScript statements can be coded on a Web page using two different techniques:
o A container tag
o May be placed in either the head or the body section of a Web page
o Example
JavaScript Examples
Example 1: The use of the alert box and internal documentation (comments) in JavaScript.
<html>
<head>
<title>2057 JavaScript</title>
<script language="JavaScript" type="text/javascript">
/* multi-line comment,
this is a huge block of
text that I;ve commented
out */
// single line comment - put up an alert box, to show how they work
alert("Hello to your first JavaScript");
</script>
</head>
<body>
</body>
</html>
<html>
<head>
<title>2057 JavaScript</title>
<script language="JavaScript" type="text/javascript">
// put up an alert boxes, to show how they work
alert("Here's the first one");
alert("The second one");
alert("And the third one");
</script>
</head>
<body>
<h1>Yes, I have seen these and now I know it!</h1>
</body>
</html>
Example 3: The use of link events in JavaScript and internal documentation(comments) in HTML.
<html>
<head>
<title>2057 JavaScript</title>
<script language="JavaScript" type="text/javascript">
</head>
<body>
<h1>Link Events Example</h1>
<html>
<head>
<title>2057 JavaScript</title>
<script language="JavaScript" type="text/javascript">
</head>
<body>
<h1>Image Swapping Example</h1>
</body>
</html>
NOTE: You will need two images that are the same size (height and width) and in your Web page directory. The example
above uses the images named ‘smallibm.gif’ and ‘swoosh.gif’.
Next Step
If you can meet the objectives stated at the beginning of Lesson 9, you are ready to proceed to the next lesson. Keep in
mind the weekly schedule recommended in the course syllabus.
Assignment