Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how do i change the colour of the alternating text

    hi guys,

    sorry as this is a rather silly question but i am a complete javascript noob. basically i found a script on the net that i could use on my site to display an alternating text sequence. i was just wondering where i would have to edit it to change the colour of the text from black to white. any helps appreciated

    Code:
    var agnt=navigator.userAgent.toLowerCase()
    var opera=(agnt.indexOf("opera") != -1)
    var webTV=(agnt.indexOf("webtv") != -1)
    var hotjava=(agnt.indexOf("hotjava") != -1)
    var layersok=(document.layers&&!hotjava)
    var doc_all=(document.all&&!webTV)
    var itsa5=(document.getElementById&&parseInt(navigator.appVersion)>=5) ? true : false;
    var Lvl=(opera?0:(doc_all?2:(itsa5?3:(layersok?1:0))));
    
    function araVob() { }
    var DisplayLine = new araVob();
    DisplayLine[1] = "";
    DisplayLine[2] = "";
    DisplayLine[3] = "";
    DisplayLine[4] = "";
    DisplayLine[5] = "";
    
    var msgCnt = 5;			// set to number of last message to display.
    /*
     to change or add messages, just replace values of or add to DisplayLine[n] 
     above.  Set msgCnt to number of lines.
    */
    var DisplayTime = 4000;		// time message is displayed (in milliseconds)
    var classfntsize="30"		// font-size for scripted text	
    var classfntfam="arial,helvetica,sans-serif"	//font-family
    var classfntwgt=600		// font-weight
    
    
    var id4css="jsid4Alternator"
    var id4layer="AlternatId"
    var id4class="Alternat"
    var sTag="<DIV id='"+id4layer+"'>"
    var eTag="<\/DIV>"
    var msgNum = 1;
    var DispMsg=""
    var msg = DisplayLine[1];
    var Lth=msg.length
    
    function DisplayMsg() {
     DispMsg="<p class='"+id4class+"'><nobr>"+msg+"<\/nobr><\/p>"
     if (Lvl>2){
      layur.firstChild.replaceData(0,Lth,msg)  
     }
     else if (Lvl==2) {
       layur.innerHTML=DispMsg
     }
     else if (Lvl==0){
       self.document.forms[0].elements[0].value=msg;
     }
     else {	// Lvl==1
      if (self.innerWidth != strtWidth) {
       window.location.reload()
      }
      else {
       layur.document.write(DispMsg)
       layur.document.close()
      }
     }
     setTimeout("ChangeMsg()",DisplayTime);
    }
    
    function ChangeMsg() {
     msgNum++;
     if (msgCnt < msgNum) {
      msgNum = 1;}
     msg = DisplayLine[msgNum];
     DisplayMsg();
    }
    
    function NNlode(){
     if (self.innerWidth!= strtWidth||self.innerHeight!=strtHeight) {
      window.location.reload()
     }
    }
    
    for (var x=1; x<=msgCnt; x++){
     if (DisplayLine[x].length>Lth) Lth=DisplayLine[x].length
    }
    if (Lvl>0) {
     if (screen.width < 700) {classfntsize="22";}
     if (screen.width > 800) {classfntsize="22";}
     if (classfntsize>10) classfntwgt=500
     var Wdth=classfntsize*Lth
     classfntsize+="pt"
     document.writeln("<STYLE ID='"+id4css+"' TYPE='text\/css'><\/style>")
     if (Lvl==1) {
      sTag="<ilayer id='"+id4layer+"'><layer id='"+id4class+"' left=0 top=0 width="+Wdth+">"
      eTag="<\/layer><\/ilayer>"
      eval("document.classes."+id4class+".all.fontFamily=classfntfam;")
      eval("document.classes."+id4class+".all.fontSize=classfntsize;")
      eval("document.classes."+id4class+".all.fontWeight=classfntwgt;")
      
     }
     else if (Lvl==2) {
      eval("document.styleSheets['"+id4css+"'].addRule ('body', 'overflow:scroll;')")
      eval("document.styleSheets['"+id4css+"'].addRule ('#'+id4layer, 'position:absolute;')")
      eval("document.styleSheets['"+id4css+"'].addRule ('.'+id4class, 'font-family:'+classfntfam)")
      eval("document.styleSheets['"+id4css+"'].addRule ('.'+id4class, 'font-size:'+classfntsize)")
      eval("document.styleSheets['"+id4css+"'].addRule ('.'+id4class, 'font-weight:'+classfntwgt)")
      
     }
     document.writeln(sTag+eTag)
     document.write("<span class='"+id4class+"' id='"+id4class+"'> <br><\/span>")
     eval("layur =(Lvl==2?document.all."+id4layer+":(Lvl==3?document.getElementById('"+id4class+"'):(Lvl==1?document."+id4layer+".document."+id4class+":'')));")
    }
    else{
    document.write(" <p><form name= 'msgform' action=' '>"
     +"<input class='form' type='text' name='message'"
     +" size=70 value=' Powered by JavaScript (or JScript).'"
     +" usestyle bgcolor='#ffffff' readonly><\/form><\/p><\/center>")
    }
    
    function Alternate(){
     if (Lvl==1){
      strtWidth = innerWidth;
      strtHeight = innerHeight;
      self.onresize=NNlode
     }  
     if (Lvl>2){
      layur.style.fontFamily=classfntfam
      layur.style.fontSize=classfntsize
      layur.style.fontWeight=classfntwgt
     
     }
     DisplayMsg()
    }
    
    // -->
    </script>
    thanks guys

  • #2
    New Coder
    Join Date
    May 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    take a look at what i bolded; just change blue to white or black whichever you wanted
    =)

    var id4css="jsid4Alternator"
    var id4layer="AlternatId"
    var id4class="Alternat"
    var sTag="<DIV id='"+id4layer+"' style='color:blue'>"
    var eTag="<\/DIV>"
    var msgNum = 1;
    var DispMsg=""
    var msg = DisplayLine[1];
    var Lth=msg.length


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •