I have a script to display a moving text in the status bar. I also
want to display the change of ShowHead and ShowTail variables in the
page. I wrote a
function w()to do this. But it caused an error after it ran. Could
you tell me what is wrong? Thanks a lot.
Here is the code:
<html>
<head>
</head>
<body><script >
var ShowString = " " //The
first line must be blank
+ "JavaScript Scrolling Text Demo is here... "
var ShowWidth = 1000
var ShowHead = 0
var ShowTail = ShowWidth
var ShowLength = ShowString.leng th
function Marquee(){
var DisplayString
if (ShowHead < ShowTail)
DisplayString = ShowString.subs tring(ShowHead, ShowTail)
else
DisplayString = ShowString.subs tring(ShowHead, ShowLength)
+ ShowString.subs tring(0, ShowTail)
ShowHead = (ShowHead + 1 ) % ShowLength
ShowTail = (ShowTail + 1 ) % ShowLength
window.status = DisplayString
TimerID = setTimeout("Mar quee()",200)
}
Marquee();//above is OK.
function w(){
document.write( ShowHead +" "+ ShowTail);
setTimeout("w() ",200);
}
w();
</script>
</body>
</html>
want to display the change of ShowHead and ShowTail variables in the
page. I wrote a
function w()to do this. But it caused an error after it ran. Could
you tell me what is wrong? Thanks a lot.
Here is the code:
<html>
<head>
</head>
<body><script >
var ShowString = " " //The
first line must be blank
+ "JavaScript Scrolling Text Demo is here... "
var ShowWidth = 1000
var ShowHead = 0
var ShowTail = ShowWidth
var ShowLength = ShowString.leng th
function Marquee(){
var DisplayString
if (ShowHead < ShowTail)
DisplayString = ShowString.subs tring(ShowHead, ShowTail)
else
DisplayString = ShowString.subs tring(ShowHead, ShowLength)
+ ShowString.subs tring(0, ShowTail)
ShowHead = (ShowHead + 1 ) % ShowLength
ShowTail = (ShowTail + 1 ) % ShowLength
window.status = DisplayString
TimerID = setTimeout("Mar quee()",200)
}
Marquee();//above is OK.
function w(){
document.write( ShowHead +" "+ ShowTail);
setTimeout("w() ",200);
}
w();
</script>
</body>
</html>
Comment