PDA

View Full Version : Before and After Message in same line (Javascript) ?


morrisdan1
02-25-2001, 04:56 PM
Shown below, is a Text Rotater that counts from zero to five.

I'm having difficulty trying to figure out how to write the text "Counting from Zero to Five" and the text strings "Zero", "One", "Two", "Three", "Four" and "Five" on the same line ?

Apparently, it seems that "Counting from Zero to Five" would be written on one line. And the strings would be written in the next line.

I'm not sure where within the Javascript codes shown below would fix that problem ? Please advise. I'd appreciate it. Thanks ![nbsp][nbsp]

<script language=&quot;JavaScript&quot;>
[nbsp][nbsp]<!-- Begin
[nbsp][nbsp][nbsp][nbsp]var beforeMsg = &quot;Counting from Zero to Five <font color='#000000' face='times new roman'>&quot;;
[nbsp][nbsp]var afterMsg = &quot;</font>&quot;;
[nbsp][nbsp]var msgRotateSpeed = 946; // Rotate delay in milliseconds
[nbsp][nbsp]var textStr = new Array();

[nbsp][nbsp]textStr[0] = &quot;Zero&quot;;
[nbsp][nbsp]textStr[1] = &quot;One&quot;;
[nbsp][nbsp]textStr[2] = &quot;Two&quot;;
[nbsp][nbsp]textStr[3] = &quot;Three&quot;;
[nbsp][nbsp]textStr[4] = &quot;Four&quot;;
[nbsp][nbsp]textStr[5] = &quot;Five&quot;;

[nbsp][nbsp]if (document.layers) {
[nbsp][nbsp][nbsp][nbsp]document.write('<ilayer id=&quot;NS4message&quot; height=25 width=100%><layer id=&quot;NS4message2&quot; height=25 width=100%></layer></ilayer>')
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]temp = 'document.NS4message.document.NS4message2.document.write(beforeMs g + textStr[i++] + afterMsg);'+
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]'document.NS4message.document.NS4message2.document.close()';
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]}
[nbsp][nbsp]else if (document.getElementById) {
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] document.write(beforeMsg + '<div id=&quot;message&quot; style=&quot;position:relative;&quot;>IE division</div>' + afterMsg);
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] temp = 'document.getElementById(&quot;message&quot;).firstChild.nodeValue = textStr[i++];';
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]}
[nbsp][nbsp]else if (document.all) {
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] document.write(beforeMsg + '<div id=&quot;message&quot; style=&quot;position:relative;&quot;>IE division</div>' + afterMsg);
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] temp = 'message.innerHTML = textStr[i++];';
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]}
[nbsp][nbsp]var i = 0;
[nbsp][nbsp]function msgRotate() {
[nbsp][nbsp][nbsp][nbsp]eval(temp);
[nbsp][nbsp][nbsp][nbsp] if (i == textStr.length) i = 0;
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] setTimeout(&quot;msgRotate()&quot;, msgRotateSpeed);
[nbsp][nbsp][nbsp][nbsp] }
[nbsp][nbsp][nbsp][nbsp] window.onload = msgRotate;
[nbsp][nbsp][nbsp][nbsp] //[nbsp][nbsp]End -->
[nbsp][nbsp] </script>