Lab 5—Your First JavaScripts

Part 1—Create a header script


 

Now add a JavaScript to the head of your HTML page:

  1. Open lab05.html in NotePad++.
  2. Save the file as header.html.
  3. Change the title of your page to "Header Script by " and your name; for example, "Header Script by Joy."
  4. After the end </title> tag, add your script tags so the Web browser knows it's JavaScript. Between the script tags, add an alert that will pop up with a message to the user. The message is in quotes.

    <script type="text/javascript">
        alert("This script is a header script!");
    </script>

  5. Go down to the <body> section of the HTML page. After the start <body> tag, add some content that will show on the screen. Add an <h1> heading and a paragraph.
  6. Save the file again.

 

Next, you'll create a body script and compare the two.

 
previous page   next page