This tag is used to separate the JavaScript code from the remainder of the HTML code. The type attribute should have the value of "text/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 type="text/javascript">Note the line before the <script> tag also contains a JavaScript comment. The use of the JavaScript comment is very important.
<!-- This is the HTML Comment that hides the JavaScript code from old browsersJavaScript 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 http://www.w3schools.com/htmldom/dom_obj_document.asp for a discussion of more items.
The document.write() method allows text information (strings) to be added to the the HTML code. The parameter of the method (the stuff placed between the parentheses) can be a single string or a multiple strings separated by commas. Whatever is written will then be interpreted by the web browser as HTML code, so you can include HTML tags to help format the information being written.
The document.URL property gives the URL of the current page.
The document.lastModified property gives the date and time that the web page was last modified. Note this property gives the information as a Date object.
The Date object allows JavaScript code to retrieve specific information about the date stored in the Date object. See http://www.w3schools.com/js/js_obj_date.asp for addition information about the Date object.
This will create a new Date object with the current date and time.
The above methods will return the specified data when used with a Date object that alread has a date stored in it.
For this lab assignment, complete the following:
Verify that your link and the file are viewable via a web browser from the URL of:
http://www.cs.uic.edu/~USERID where USERID is your CS account login name.You can check this out via the link to your home page on the CS 101 Student List page. Once you are at your home page, follow the link you added to your home page for this lab assignment.
To use the UNIX turnin command to electronically hand-in your html file using the project name of lab4. To submit the file in <filename> for lab4, the turnin command is entered as:
turnin -c cs101 -p lab4 <filename>Thus if your file has the name of lab4.html, the command would be:
turnin -c cs101 -p lab4 lab4.htmlTo verify what you submitted using the turnin command type:
turnin -c cs101 -p lab4 -v