CS 101 - Lab 5

Due at end of lab during sixth week

JavaScript

<script> </script> - attributes: language

This tag is used to separate the JavaScript code from the remainder of the HTML code. The language attribute should have the value of "JavaScript". Also in case the browser viewing the page does not recognize the JavaScript code, all of the code should be enclosed in an HTML comment. The following example shows this done.

<script language="JavaScript">
<!-- This is the HTML Comment that hides the JavaScript code from old browsers

JavaScript code goes here

// stop hiding the JavaScript code -->
</script>

The JavaScript code can add dynamic information to a web page that static HTML code cannot. The use of the JavaScript statement document.write() is very useful for this.

The document object in JavaScript allows a number of useful methods and properties. Check out chapter 16 in the text for a discussion of more items than covered here. We will

The Date object allows JavaScript code to retrieve specific information about the dat stored in the Date object.

Lab Assignment

Create an HTML file that lists:
  1. your name
  2. day and time of your CS 101 lab section (i.e. Wendesday at 9:00)
  3. the URL of the web page (using the document.URL property)
  4. the month, day and year when the web page was last modified (using the document.lastModified property)
  5. the "current" time in hours and minutes. By "current" time, list the time when the page was load. You do not have to keep updating the time value as every minute passes.
Submit this file to the Digital Drop box.