Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it L'avatar di Donovant
    Registrato dal
    Sep 2005
    residenza
    London
    Messaggi
    1,329

    Effetto "fade", ma non funziona....?!?

    Il codice in javascript è questo:

    Codice PHP:
    function setOpa(obj,opa){
        
    // IE/Win
            
    obj.style.filter "alpha(opacity:"+opa+")";
            
    // Safari<1.2, Konqueror
            
    obj.style.KHTMLOpacity opa/100;
            
    // Older Mozilla and Firefox
            
    obj.style.MozOpacity opa/100;
            
    // Safari 1.2, newer Firefox and Mozilla, CSS3
            
    obj.style.opacity opa/100;
    }

    function 
    opacitaIn(obj,opa){
        
        if(!
    document.getElementById) return;
        
        if(
    opa <= 100){
             
    setOpa(obj,opa);
             
    opa += 5;
             
    //window.setTimeout("opacitaIn('"+obj+"',"+opa+")", 1500);
             //window.setTimeout(opacitaIn(obj,opa), 1500);
        
    }
            

    HTML:

    Codice PHP:
    <li id="mHome" class="kwick" onmouseover="opacitaIn(this,100);" onmouseout="opacitaOut(this,50);" >[url="#"]Home[/url
    CSS: nel css ho impostato l'opacità iniziale al 50%

    Il problema è che anche attivo uno dei due "setTimeout", l'opacità cambia istantaneamente e non con effetto "fade" (crescente).
    Grazie a tutti per il futuro aiuto
    Beati gli smemorati, perchè avranno la meglio anche sui loro errori...

    My gallery: http://donovant.deviantart.com/gallery/

  2. #2
    Utente di HTML.it L'avatar di Donovant
    Registrato dal
    Sep 2005
    residenza
    London
    Messaggi
    1,329
    Aiutoooo?!?!?!!
    Beati gli smemorati, perchè avranno la meglio anche sui loro errori...

    My gallery: http://donovant.deviantart.com/gallery/

  3. #3
    Prova a fare:

    Codice PHP:
    function setOpa(obj,opa){ 
        
    // IE/Win 
            
    obj.style.filter "alpha(opacity:"+opa+")"
            
    // Safari<1.2, Konqueror 
            
    obj.style.KHTMLOpacity opa/100
            
    // Older Mozilla and Firefox 
            
    obj.style.MozOpacity opa/100
            
    // Safari 1.2, newer Firefox and Mozilla, CSS3 
            
    obj.style.opacity opa/100


    function 
    opacitaIn(){ 
         
        if(!
    document.getElementById) return; 
         
        if(
    opaC <= 100){ 
             
    setOpa(objE,opaC); 
             
    opaC += 5
        } 
        else
            
    clearInterval(interval);
             
    }

    var 
    opaCobjE;
    var 
    interval;

    function 
    start(id){
       
    opaC 50;
       
    objE document.getElementById(id);
       
    interval setInterval(opacitaIn500)

    Basta che chiami start('mHome')

  4. #4
    Prova questa (da stato normale a fade):

    Codice PHP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <
    script type="text/JavaScript">
    function 
    setOpacity(el,value) { 
        
    el.style.opacity value/10
        
    el.style.mozOpacity value/10
        
    el.style.filter 'alpha(opacity=' value*10 ')'

    function 
    fade(el,stop){ 
        var 
    opt10
       var 
    timeoutID window.setInterval(f100); 
        var 
    selfel
        function 
    f(){     
            if(
    opt>stop){ 
                
    opt--; 
                
    setOpacity(self,opt); 
            } 
            else { 
                
    window.clearTimeout(timeoutID); 
            } 
        } 

    </script>

    </head>

    <body>
    <div id="myDiv" style="width:200px; height:200px; background-color:#0066FF" onClick="fade(this,'1')"></div>

    </body>
    </html> 
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  5. #5
    Utente di HTML.it L'avatar di Donovant
    Registrato dal
    Sep 2005
    residenza
    London
    Messaggi
    1,329
    Ho provato come "wisher" ma niente....

    function opacitaIn(obj,opa){
    /*document.getElementById("mHome").style.color="#aa aaaa";*/
    if(!document.getElementById) return;

    var timeId = window.setInterval(op(),300);
    var ob = obj;
    var alpha = opa;

    function op(){
    if(alpha < 100){
    alpha += 5;
    setOpa(ob,alpha);
    }
    else window.clearInterval(timeId);
    }
    //window.setTimeout("opacitaIn('"+obj+"',"+opa+")", 1500);
    //setTimeout(opacitaIn(obj,opa), 300);
    }

    Il "setPoa()" l'ho lasciato nel mio modo che è cmq corretto.
    Maah non capisco!
    Beati gli smemorati, perchè avranno la meglio anche sui loro errori...

    My gallery: http://donovant.deviantart.com/gallery/

  6. #6
    Utente di HTML.it L'avatar di Donovant
    Registrato dal
    Sep 2005
    residenza
    London
    Messaggi
    1,329
    Risolto...avevo messo la parentesi "()" in setInterval(fade(),100); per la funzione fade()....mentre in set interval probabilmente per indicare la funzione si mette solo il nome.
    Beati gli smemorati, perchè avranno la meglio anche sui loro errori...

    My gallery: http://donovant.deviantart.com/gallery/

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 © 2025 vBulletin Solutions, Inc. All rights reserved.