1 <HTML> 2 <HEAD> 3 <TITLE>JavaScript Example: Scrolling text</TITLE> 4 5 <SCRIPT LANGUAGE="JavaScript"> 6 <!-- hide script from old browsers 7 8 var text = "Welcome to the Short Course on Web Technologies!"; 9 var len = text.length; 10 var width = 125; 11 var pos = 1 - width; 12 13 function scrollText() { 14 pos++; 15 var scroller = ""; 16 if ( pos == len ) { 17 pos = 1 - width; 18 } 19 if ( pos < 0 ) { 20 for ( var i = 1; i <= Math.abs(pos); i++ ) { 21 scroller += " "; 22 } 23 scroller += text.substring(0,width-i+1); 24 } else { 25 scroller += text.substring(pos,width+pos); 26 } 27 window.status = scroller; 28 window.setTimeout("scrollText()", 150); // 150 millisecs = .15 secs 29 } 30 31 // end script hiding --> 32 </SCRIPT> 33 34 </HEAD> 35 36 <BODY BGCOLOR="#FFFFFF" onLoad="scrollText(); return true;"> 37 38 Look at the status line of this window!!! 39 40 </BODY> 41 </HTML>