Technique below is the source program of the effect of the horse lamp we produced
<script language= "JavaScript" >
!--Hide
var scrtxt= "The message here can be changed to what you have to tell people." + "
Or attention matters ... ";
var lentxt=scrtxt.length;
var width=100;
var pos=1-width;
function Scroll () {
pos++;
var scroller= "";
if (pos==lentxt) {
Pos=1-width;
}
if (pos<0) {
for (var I=1; I<=math.abs (POS); i++) {
Scroller=scroller+ "";}
Scroller=scroller+scrtxt.substring (0,width-i+1);
}
else {
Scroller=scroller+scrtxt.substring (Pos,width+pos);
}
Window.status = scroller;
SetTimeout ("Scroll ()", 150);
}
-->
</script>
<body >
Here goes your cool page!
</body>
In this program we use the same function (or part) settimeout (...) as above. Notice that the timer goes to call the scroll () function in time to make the text in the marquee move forward into a grid. At the beginning of the function, there are some more verbose computations, but it's not hard to understand that these calculations are mainly used to get the use of the text in the marquee to be displayed by that position. The beginning of course is necessary to add some white space on the left side of the word, so that the text can be as far as possible to the right, and then a word will be blank reduction, the result of nature will cause the word forward movement effect.