[IMAGE] IU SLIS logo

Demo page logo

Javascript

Here's a textbox that will scroll through and display a set of text messages

Here is the script that makes it work

The script is in three parts. The first part is in the <head> of the document. The second part is in the <body> tag. The third part is in the <body> of the document

The script uses familiar form markup

Here's the first part:

<script language=javascript type="text/javascript">

<!-- Hide from older browsers
var max=0;
function textlist() {
max=textlist.arguments.length;
for (i=0; i this[i]=textlist.arguments[i];
}

tl = new textlist(
"Your text goes here",
"And here",
"Here too",
"And here",
"OK. Now you try."
);

var x = 0; pos = 0;
var l = tl[0].length;
function textticker() {
document.tickform.tickfield.value = tl[x].substring(0, pos) + "~";

if(pos++ == l) {
pos = 0;
setTimeout("textticker()", 2000);
if(++x == max) x = 0;
l = tl[x].length;
} else
setTimeout("textticker()", 50);
}
// End hiding-->
</script>

Here's the second part:

<body bgcolor="#ffffff" OnLoad="textticker()">

Here's the third part:

<form name="tickform">

<textarea name="tickfield" rows="2" cols="60" style="background-color: rgb(0,0,0); color: rgb(255,255,255); cursor: default; font-family: Arial; font-size: 12px" wrap="virtual"> Just give it a chance, OK?</textarea>

</form>

Return to Javascript for home use.


Page by Howard Rosenbaum
Find me at hrosenba@indiana.edu http://www.slis.indiana.edu/hrosenba/www/Demo/ticker.html