<HTML>
<HEAD>
<TITLE>Date, Alert and Scroller Scripts</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--Hide from old browsers
/* This SCROLLING MESSAGE SCRIPT uses the Document, Form, String and Input Objects.
It also uses Properties, Methods and Event Handlers. */
// Declare a variable and assign it a string.
var ScrollText = "Active Server Pages are Cool and Fun!" // I teach ASP Part 1.
// Declare a variable and assign a string to it which will be the space between the message text.
var ScrollerTextSpace = " < < < < "
// Declare a variable and assign it a value.
var StartPlace = 0
// Create a function called Scroller()
function Scroller() {
/* 1. Assign variables created above (see right of equals sign) to the Document Object which is derived
from the Form Object and the Input Object (see left of equals sign).
2. Notice that ScrollForm is the Form Object name (see HTML FORM below)
and that ScollMessage is the Input Object name (see INPUT below).
3. Look up the substring Method and the length Property of the String
Object in the JScript Language Reference. */
document.ScrollForm.ScrollMessage.value = ScrollText.substring(StartPlace,ScrollText.length)+ScrollerTextSpace+ScrollText.substring(0,StartPlace)
// Increase the StartPlace variable which was set to zero by one.
StartPlace = StartPlace + 1
// Use an If Statement to determine if the current value of StartPlace is greater than the message length.
if (StartPlace > ScrollText.length) {
// If StartPlace is greater than the message length, then set StartPlace back to zero.
StartPlace=0
}
/* Use the setTimeout Method of the Window Object to call the Scroller function.
By calling the same function from within the function, recursion is used to
make the message scroll continuously. This occurs every 200 milliseconds. */
window.setTimeout("Scroller()",200)
}
//-->
</SCRIPT>
</HEAD>
<!-- Add an onload Event Handler to call the Scroller function when the user visits or loads the page. -->
<BODY onload="Scroller()">
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--Hide from old browsers
/* This LAST DATE MODIFIED SCRIPT uses a property of the Document Object. */
// The Document Object has a lastModified Property which is used to retreive the last change date.
document.write("<FONT COLOR='blue'><H5>Last modified "+document.lastModified+"</H5></FONT>")
//-->
</SCRIPT>
<!--
Review HTML FORMS at www.utexas.edu/cc/training/handouts/htmlform/
Create an HTML form named ScrollForm.
-->
<FORM Name="ScrollForm"> <INPUT Type="text" Name="ScrollMessage" Size="26"> </FORM><SCRIPT LANGUAGE="JAVASCRIPT">
<!--Hide from old browsers
/* This ALERT SCRIPT uses a Method and Property of the Window Object. */
// Create a function.
function NewSite() {
/* Use the alert Method of the Window Object (Search for alert and click message boxes in
the JScript Language Reference.) */
alert("You'll be taken to CNN.")
/* Use the location Property of the Window Object and assign it a string (URL) causing the
browser to display that URL. */
location = "http://www.cnn.com"
}
//-->
</SCRIPT>
<!-- Use the onclick Event Handler to call the function -->
<a href="http://www.cnn.com" onclick="NewSite()">Alert and go to another site</a>.
</BODY>
</HTML>