Visualizzazione dei risultati da 1 a 4 su 4

Discussione: sfondo dinamico

  1. #1

    sfondo dinamico

    Ciao a tutti, ho implementato un semplice box con delle miniature d' immagini, al passaggio del mouse lo sfondo cambia dinamicamente, tutto bene, l' unica cosa è che se assegno come sfondo iniziale un' immagine invece che un colore, non modifica più lo sfondo.
    Segue lo script

    <div id="cambiasfondo">
    [img]background/ssfondo1.png[/img]
    [img]background/ssfondo2.png[/img]
    [img]background/ssfondo3.png[/img]
    [img]background/ssfondo4.png[/img]
    [img]background/ssfondo5.png[/img]
    [img]background/ssfondo6.png[/img]
    [img]background/ssfondo7.png[/img]
    [img]background/ssfondo8.png[/img]
    [img]background/ssfondo9.png[/img]
    </div>

    <script type="text/javascript">
    var backImage = new Array();

    backImage[0] = "background/sfondo1.png";
    backImage[1] = "background/sfondo2.png";
    backImage[2] = "background/sfondo3.png";
    backImage[3] = "background/sfondo4.png";
    backImage[4] = "background/sfondo5.png";
    backImage[5] = "background/sfondo6.png";
    backImage[6] = "background/sfondo7.png";
    backImage[7] = "background/sfondo8.png";
    backImage[8] = "background/sfondo9.png";
    backImage[9] = "";

    function changeBGImage(whichImage)
    {

    if (document.body)
    {
    document.body.background = backImage[whichImage];
    }

    }
    </script>
    Mi chiedo sinceramente il perchè??

  2. #2
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998

    Re: sfondo dinamico

    Originariamente inviato da gorgeita
    ... se assegno come sfondo iniziale un' immagine invece che un colore,
    Con quale codice?

    ciao
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

  3. #3
    ho provato sia nel css,
    body{
    background:url(sfondo.png)-no repeat;
    }
    che con uno stile inline nell' xhtml
    <body style="backgroundurl);">

    Ma niente, se invece gli assegni un colore background-color:green; tutto a posto.
    Sinceramente non capisco.

  4. #4
    Ho aggirato il problema così:
    <body onload="ChangeBGImage(0)">

    Anche se non mi pare una soluzione molto standard, non capisco perchè non posso semplicemente assegnare un' immagine di sfondo, mentre un colore sì.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.