Article ID: 167596
Article Last Modified on 6/18/2005
<SCRIPT> <!-- </SCRIPT> //-->Insert the following script into your normal HTML Web page:
<SCRIPT LANGUAGE="JavaScript">
<!--
// Scrolling text string.
var scrollString = "Replace this string with your text."
// Width of the scrolling area.
var width = 120;
var stringLength = scrollString.length;
var pos = 1 - width;
// Start far enough to the left so that only one letter shows.
function ScrollMessage(){
var ScrollMessage = "";
// Initialize the string to be printed.
pos++;
// Move to the right in the string.
if (pos == stringLength)
// Start over if the string is done.
pos = 1 - width;
// Scrolling
if (pos<0) {
// Add spaces to beginning if necessary.
for (var i=1; i<=Math.abs(pos); i++)
ScrollMessage = ScrollMessage + " ";
ScrollMessage = ScrollMessage;
+ scrollString.substring(0, width;
- i + 1);
}
else
ScrollMessage = ScrollMessage;
+ scrollString.substring(pos, pos +;
width);
window.status = ScrollMessage;
// Print the string.
setTimeout("ScrollMessage()",100);
// Repeat after 1/10 second.
}
//-->
</SCRIPT>
In order for the message to function, modify the <BODY> tag so that it
looks like this:
<BODY OnLoad="ScrollMessage()">
var strText="This is a scrolling message!";
var intText=strText.length;
var intSpeed=25;
var intWidth=100;
var intPos=1-intWidth;
function scroll()
{
intPos++;
var strScroll="";
if (intPos==intText)
{
intPos=1-intWidth;
}
if (intPos<0)
{
for (var i=1; i<=Math.abs(intPos); i++)
{
strScroll=strScroll+" ";
}
strScroll=strScroll+strText.substring(0, intWidth-i+1);
}
else
{
strScroll=strScroll+strText.substring(intPos,intWidth+intPos);
}
window.status = strScroll;
setTimeout("scroll()", intSpeed);
}
Additional query words: 97
Keywords: kbinfo kbcode KB167596