Help - Search - Members - Calendar
Full Version: i need some help with javascript
OverclockersClub Forums > Operating Systems & Software Support > Programmer's Corner
nightsider
hi all, I'm trying to make a web page and part of the content is a scrolling list, as i don't know javascript at all Ive had to customize a free script.

my problem is that i cant change the color of the text in the list, and as a result it blends into the page background and is unreadable.

can some one please hep me to change the color of the scrolling list please.

CODE
<style type="text/css">
<!--
#Layer1 {
    position:left;
    
}
-->
</style>


<center>
</center>



<script type="text/javascript">
    var charIndex = -1;
    var stringLength = 0;
    var inputText;
    function writeContent(init){
        if(init){
            inputText = document.getElementById('contentToWrite').innerHTM  L;
        }
        if(charIndex==-1){
            charIndex = 0;
            stringLength = inputText.length;
        }
        var initString = document.getElementById('myContent').innerHTML;
        initString = initString.replace(/<SPAN.*$/gi,"");

        var theChar = inputText.charAt(charIndex);
           var nextFourChars = inputText.substr(charIndex,4);
           if(nextFourChars=='<BR>' || nextFourChars=='<br>'){
               theChar  = '<BR>';
               charIndex+=3;
           }
        initString = initString + theChar + "<SPAN id='blink'>_</SPAN>";
        document.getElementById('myContent').innerHTML = initString;

        charIndex = charIndex/1 +1;
        if(charIndex%2==1){
             document.getElementById('blink').style.display='no  ne';
        }else{
             document.getElementById('blink').style.display='in  line';
        }

        if(charIndex<=stringLength){
            setTimeout('writeContent(false)',90);
        }else{
            blinkSpan();
        }
    }

    var currentStyle = 'inline';
    function blinkSpan(){
        if(currentStyle=='inline'){
            currentStyle='none';
        }else{
            currentStyle='inline';
        }
        document.getElementById('blink').style.display = currentStyle;
        setTimeout('blinkSpan()',300);

    }
    
    
msg = "test";

msg = " " + msg;pos = 0;
function scrollMSG() {
document.title = msg.substring(pos, msg.length) + msg.substring(0, pos);
pos++;
if (pos >  msg.length) pos = 0
window.setTimeout("scrollMSG()",200);
}
scrollMSG();
</script>
<center>
<table width="572" height="215">
<tr>
<td width="364">
<div id="myContent" class="tip">
</div>
<div id="contentToWrite" style="display:none" text-decoration:"overline" class="tip">

<br />text 1
<br>
<br /> text 2
<br>
<br /> text 3
<br>
<br /> text 4
<br>
<br />  text 5
<br>
<br /> text 6
<br>
<br />  text 7
<br>
<br /> text 8
<br>
<br />  text 9
<br>
<br />  text 10
<br>
<br />  text 11
<br>
<br /> text 12
<br>
<br /> text 13
<br>
<br /> text 14






</div>

</td>
</tr>
</table>


<table class="listing">
<tr>

<td class="listing">

</td>

</tr>
</table>
<p>&nbsp;  </p>
<p>
  <script type="text/javascript">
writeContent(true);
  </script>
</p>
</center>
ClayMeow
Any reason you don't want to just use a scrollable div?
nightsider
i dident wright the code im having to customize a free script as i dont know JS
d3bruts1d
CODE
<html>
<head>
<script type="text/javascript">
var charIndex = -1;
var stringLength = 0;
var inputText;

function writeContent(init){
    if(init){
        inputText = document.getElementById('contentToWrite').innerHTML;
    }
    if(charIndex==-1){
        charIndex = 0;
        stringLength = inputText.length;
    }
    
    var initString = document.getElementById('myContent').innerHTML;
    
    initString = initString.replace(/<SPAN.*$/gi,"");
    
    var theChar = inputText.charAt(charIndex);
    var nextFourChars = inputText.substr(charIndex,4);
    if(nextFourChars=='<br />' || nextFourChars=='<br>'){
        theChar  = '<br />';
        charIndex+=3;
    }
    
    initString = initString + theChar + "<SPAN id='blink'>_</SPAN>";
    document.getElementById('myContent').innerHTML = initString;
    
    charIndex = charIndex/1 +1;
    
    if(charIndex%2==1){
        document.getElementById('blink').style.display='none';
    }else{
        document.getElementById('blink').style.display='inline';
    }
    
    if(charIndex<=stringLength){
        setTimeout('writeContent(false)',90);
    }else{
        blinkSpan();
    }
}

var currentStyle = 'inline';

function blinkSpan(){
    if(currentStyle=='inline'){
        currentStyle='none';
    }else{
        currentStyle='inline';
    }

    document.getElementById('blink').style.display = currentStyle;
    setTimeout('blinkSpan()',300);
}

msg = "test";

msg = " " + msg;pos = 0;

function scrollMSG() {
    document.title = msg.substring(pos, msg.length) + msg.substring(0, pos);
    pos++;
if (pos >  msg.length) pos = 0
    window.setTimeout("scrollMSG()",200);
}
scrollMSG();
</script>
</head>

<body onload="writeContent(true);">
<center>
<table width="572" height="215">
<tr>
<td width="364">
<div id="myContent" class="tip">
</div>

<div id="contentToWrite" style="display:none;" class="tip">
<br />text 1
<br />
<br />text 2
<br />
<br />text 3
<br />
<br />text 4
<br />
<br />text 5
<br />
<br />text 6
<br />
<br />text 7
<br />
<br />text 8
<br />
<br />text 9
<br />
<br />text 10
<br />
<br />text 11
<br />
<br />text 12
<br />
<br />text 13
<br />
<br />text 14
</div>
</td>
</tr>
</table>

<table class="listing">
<tr>
<td class="listing">
</td>
</tr>
</table>
</center>
</body>
</html>
ClayMeow
QUOTE (nightsider @ Aug 7 2009, 01:47 PM) *
i dident wright the code im having to customize a free script as i dont know JS

My point being that you don't even need javascript if all you want to do is scroll text unless you're customizing the actual scrollbar.
nightsider
i dont remmeber seeing a html funct that could scrol text but yet again i could be wrong
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.