hitmill.com
hitmill.com home


 

The JavaScript Banner Tutorial

JavaScript Banner Script

(I left a banner box inside a banner form, at the top of the page, so you can see what size of 68 looks like.)

 
<HTML>
<HEAD>
<TITLE></TITLE>
 
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from old browsers
var id,pause=0,position=0,revol=34;
function banner() {
 var i,k;
 var l1=" ";<!-- first line -->
 var l2=" last line";
 var l3=" second line";
 var l4=" ";
 var l5=" ";
 var l6=" ";
 var msg=l1+l3+l4+l5+l6+l2; This coding will determine line order; (These are not numbers between 10 and 17, but the letter "el" before one through six.) Arrange the line numbers in any order you like. They display in chronological order of coding in "var msg=", not by line number value. In the var message=" " code line above, line l2 will display last, because I listed that value last in the code.
 var speed=9;
 document.form1.banner.value=msg.substring(position,position+50);Please code this without a line break, as a single line with the line beginning with "document.form1.banner.value"
 
 if(position++==msg.length) {
  if (revol-- < 2) return;
  position=0;
 }
 id=setTimeout("banner()",1000/speed);
 }
 // end -->
</SCRIPT>
 
</HEAD>
 
<BODY BGCOLOR="white" onload="banner()">
<DIV ALIGN="center">
<FORM NAME="form1"><!-- This is the form holding the banner object --> <INPUT TYPE="text" NAME="banner" SIZE="68"> </FORM>
</DIV>
 
</BODY>
</HTML>


 

Banner speed is set in the line beginning "id=setTimeout". A speed of 800/speed is faster than 1000/speed. 2000/speed is much slower. Play with the speeds to get one you like. Change speed in increments of 100 or 200.

Banner width is changed in the form, within the body section in the <INPUT TYPE="text" NAME="banner" SIZE="68"> line. Changing this size value to a lesser integer will make the banner narrower and changing the value to a greater integer will make the banner wider.

webmaster@hitmill.com
 
Updated 14 Dec 2012
© hitmill.com
All Rights Reserved