Jump to content

News Scroll Script.


Ruud

Recommended Posts

I have the following script however I can't figure out how to set it to 1 row without that there appears a scroll bar. Also it has the problem that it displayes the items 2 times instead of only once...

<html><head><title>Mainpage Mag</title><link rel="stylesheet" type="text/css" href="css/general.css" /></head><body><script  language="javascript"  type="text/javascript">function AraVob() {}var ScreenLine = new AraVob();ScreenLine[1]  = "News";ScreenLine[2]  = "More news";ScreenLine[3]  = "Even more news";ScreenLine[4] = "The news does not stop";var msgNum = 1;		  // set to first message to displayvar msgCnt = 4;		 // set to number of last ScreenLine to display.var typeSpeed = 50;	  // the rate in milliseconds to scroll to top (higher number is slower)var lineDelay = 2000	 // the delay time at end of line. (unless the line is a single space)var pagLen = 1;		  // number of lines per page (usually the number of rows in the TEXTAREA)var delay = typeSpeed;var timerPS = null;var linPntr = 0;var tally = 1;var msg = " ";var outMsg = "";var i = 0;var cr="\r\n"if ("3" <=navigator.appVersion.charAt(0)) {var cr="\n"}else {  ScreenLine[11]="	You will need to upgrade your browser."}if (32<=navigator.userAgent.length && navigator.userAgent.substring(25,32)=="Opera/3") {  ScreenLine[10]="Your version of Opera show's a moving scroll bar button when you"  ScreenLine[12]="  but the frame may not appear to be scrolling."+cr}// set up ScreenLines for displayfor (x = msgCnt; 1 <= x; x--) {  ScreenLine[x+pagLen] = ScreenLine[x] + cr;}for (x = 1; x <= (pagLen); x++) {  ScreenLine[x] =  " " +cr;}msgCnt +=  pagLen;msg = ScreenLine[1];// end setupfunction DisplayScroll() {if (msgNum < pagLen) {  delay = typeSpeed;}else {  delay = lineDelay;}ChangeMsg();outMsg += msg;self.document.msgform.elements[0].value = outMsg;  timerPS = setTimeout("DisplayScroll()",delay);}function ChangeMsg() {msgNum++;if (msgCnt < msgNum) {   msgNum = 1;}if (pagLen <= tally) {   chgPage();}tally++;msg = ScreenLine[msgNum];}function chgPage() {if (msgNum < pagLen) {   linPntr = msgCnt - pagLen + msgNum + 1;}else {   linPntr = msgNum - (pagLen - 1);}outMsg =   ScreenLine[linPntr];for (p = 1; p < (pagLen - 1); p++) {   linPntr++;   if (msgCnt < linPntr) {	 linPntr = 1;   }   outMsg += ScreenLine[linPntr];}}function quitDisplay() {  self.document.msgform.elements[0].value = "Scroll a Page for yourself today!";}window.onload = DisplayScroll;window.onunload = quitDisplay;// --></script><FORM NAME = "msgform" ACTION = " "><TEXTAREA NAME = "msgarea" COLS = 50 ROWS = 2>JavaScript (or JScript) Power needed.</TEXTAREA></FORM></body></html>

Link to comment
Share on other sites

Either add a div or something or replace the textarea, give it an ID, and when you want to write the message get the element by ID and assign the message to the element's innerHTML property. All of those things are explained in the Javascript references.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...