Lab 5—Your First JavaScripts

Part 1—Create a body script


 

Now add JavaScript to the body of your HTML page:

  1. Open lab05.html in NotePad++.
  2. Save the file as body.html.
  3. Change the title of your page to "Body Script by " and your name; for example, "Body Script by Joy."
  4. After the start <body> tag, add some more content to the body section that will show on the screen. Add an <h1> heading and a paragraph.
  5. After the paragraph, add 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 body script!");
    </script>


  6. Save the file again.

 

Next, you'll compare the two scripts....

previous page   next page