Visualizzazione risultati 1 fino 5 di 5

Discussione: Aggiungere colore al file "news.js"

  1. #1
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito Aggiungere colore al file "news.js"

    Ciao ho questo script che viene richiamato tramite comando "<script src..." per questo non troverete i tag iniziale e finale. Qualcuno sa dirmi come devo personalizzare il testo di output una volta letto dal file xml? Cioè per spiegarmi meglio vorrei il testo di output in grassetto color rosso.
    Codice HTML:
    //Container for ticker. Modify its STYLE attribute to customize style:
    var tickercontainer='<div id="container" style="background-color:#FFFF99;width:150px;height:120px;font:normal 10pt Verdana;border:solid 0px"></div>'
    
    //Specify path to xml file
    var xmlsource="../news.xml"
    
    ////No need to edit beyond here////////////
    //load xml file
    if (window.ActiveXObject)
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    else if (document.implementation && document.implementation.createDocument)
    var xmlDoc= document.implementation.createDocument("","doc",null);
    if (typeof xmlDoc!="undefined"){
    document.write(tickercontainer)
    xmlDoc.load(xmlsource)
    }
    
    //Regular expression used to match any non-whitespace character
    var notWhitespace = /\S/
    
    function init_ticker(){
    //Cache "messages" element of xml file
    tickerobj=xmlDoc.getElementsByTagName("xmlticker")[0]
    
    //REMOVE white spaces in XML file. Intended mainly for NS6/Mozilla
    for (i=0;i<tickerobj.childNodes.length;i++){
    if ((tickerobj.childNodes[i].nodeType == 3)&&(!notWhitespace.test(tickerobj.childNodes[i].nodeValue))) {
    tickerobj.removeChild(tickerobj.childNodes[i])
    i--
    }
    }
    document.getElementById("container").innerHTML=tickerobj.childNodes[1].firstChild.nodeValue
    msglength=tickerobj.childNodes.length
    currentmsg=2
    themessage=''
    setInterval("rotatemsg()",tickerobj.childNodes[0].firstChild.nodeValue)
    }
    
    function rotatemsg(){
    var msgsobj=tickerobj.childNodes[currentmsg]
    if (msgsobj.getAttribute("url")!=null){
    themessage='<a href="'+msgsobj.getAttribute("url")+'"'
    if (msgsobj.getAttribute("target")!=null)
    themessage+=' target="'+msgsobj.getAttribute("target")+'"'
    themessage+='>'
    }
    themessage+=msgsobj.firstChild.nodeValue
    if (msgsobj.getAttribute("url")!=null)
    themessage+='</a>'
    
    //Rotate msg and display it in DIV:
    document.getElementById("container").innerHTML=themessage
    currentmsg=(currentmsg<msglength-1)? currentmsg+1 : 1
    themessage=''
    }
    
    function fetchxml(){
    if (xmlDoc.readyState==4)
    init_ticker()
    else
    setTimeout("fetchxml()",10)
    }
    
    if (window.ActiveXObject)
    fetchxml()
    else if (typeof xmlDoc!="undefined")
    xmlDoc.onload=init_ticker
    Apprezzi l'aiuto? Offrimi un caffè!

  2. #2
    Ospite Guest

    Predefinito

    Se ho ben capito
    Dovresti modificare il div container,ovvero:
    Codice HTML:
    <div id="container" style="background-color:#FFFF99;width:150px;height:120px;font:normal   10pt Verdana;border:solid 0px"></div>

  3. #3
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    Stranamente anche io ero arrivato a questo, ma non so cosa devo aggiungere. Al massimo per ora posso cambiare "background-color" con "background:sfondo.gif" ma poi per il grassetto e il colore?
    Apprezzi l'aiuto? Offrimi un caffè!

  4. #4
    Ospite Guest

    Predefinito

    background:sfondo.gif è errato,dovresti mettere
    Codice HTML:
    background:url('sfondo.gif');
    piuttosto
    Per il grassetto e il rosso devi mettere:
    Codice HTML:
    color: #FF0000; font-weight:bold; font-size: 10pt; font-family:verdana;
    Poi però togli:
    Codice HTML:
    font:normal   10pt Verdana;

  5. #5
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    OK grazie ora funziona.
    Apprezzi l'aiuto? Offrimi un caffè!

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •