Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    541

    Vincolare Effetto neve (script) su una tabella, possibile?

    mi scuso con i mod, ma riformula MEGLIO la mia domanda....




    ho questo effetto neve... su file "snow.js" :





    //Snow - http://www.btinternet.com/~kurt.grigg/javascript

    if ((document.getElementById) &&
    window.addEventListener || window.attachEvent){

    (function(){

    //Configure here.

    var num = 30; //Number of flakes
    var timer = 30; //setTimeout speed. Varies on different comps
    var enableinNS6 = 1 //Enable script in NS6/Mozilla? Snow animation could be slow in those browsers. (1=yes, 0=no).

    //End.

    var y = [];
    var x = [];
    var fall = [];
    var theFlakes = [];
    var sfs = [];
    var step = [];
    var currStep = [];
    var h,w,r;
    var d = document;
    var pix = "px";
    var domWw = (typeof window.innerWidth == "number");
    var domSy = (typeof window.pageYOffset == "number");
    var idx = d.getElementsByTagName('div').length;

    if (d.documentElement.style &&
    typeof d.documentElement.style.MozOpacity == "string")
    num = 12;

    for (i = 0; i < num; i++){
    sfs[i] = Math.round(1 + Math.random() * 1);

    document.write('<div id="flake'+(idx+i)+'" style="position:absolute;top:0px;left:0px;width:'
    +sfs[i]+'px;height:'+sfs[i]+'px;background-color:#ffffff;font-size:'+sfs[i]+'px"><\/div>');

    currStep[i] = 0;
    fall[i] = (sfs[i] == 1)?
    Math.round(2 + Math.random() * 2): Math.round(3 + Math.random() * 2);
    step[i] = (sfs[i] == 1)?
    0.05 + Math.random() * 0.1 : 0.05 + Math.random() * 0.05 ;
    }


    if (domWw) r = window;
    else{
    if (d.documentElement &&
    typeof d.documentElement.clientWidth == "number" &&
    d.documentElement.clientWidth != 0)
    r = d.documentElement;
    else{
    if (d.body &&
    typeof d.body.clientWidth == "number")
    r = d.body;
    }
    }


    function winsize(){
    var oh,sy,ow,sx,rh,rw;
    if (domWw){
    if (d.documentElement && d.defaultView &&
    typeof d.defaultView.scrollMaxY == "number"){
    oh = d.documentElement.offsetHeight;
    sy = d.defaultView.scrollMaxY;
    ow = d.documentElement.offsetWidth;
    sx = d.defaultView.scrollMaxX;
    rh = oh-sy;
    rw = ow-sx;
    }
    else{
    rh = r.innerHeight;
    rw = r.innerWidth;
    }
    h = rh - 2;
    w = rw - 2;
    }
    else{
    h = r.clientHeight - 2;
    w = r.clientWidth - 2;
    }
    }


    function scrl(yx){
    var y,x;
    if (domSy){
    y = r.pageYOffset;
    x = r.pageXOffset;
    }
    else{
    y = r.scrollTop;
    x = r.scrollLeft;
    }
    return (yx == 0)?y:x;
    }


    function snow(){
    var dy,dx;

    for (i = 0; i < num; i++){
    dy = fall[i];
    dx = fall[i] * Math.cos(currStep[i]);

    y[i]+=dy;
    x[i]+=dx;

    if (x[i] >= w || y[i] >= h){
    y[i] = -10;
    x[i] = Math.round(Math.random() * w);
    fall[i] = (sfs[i] == 1)?
    Math.round(2 + Math.random() * 2): Math.round(3 + Math.random() * 2);
    step[i] = (sfs[i] == 1)?
    0.05 + Math.random() * 0.1 : 0.05 + Math.random() * 0.05 ;
    }

    theFlakes[i].top = y[i] + scrl(0) + pix;
    theFlakes[i].left = x[i] + scrl(1) + pix;

    currStep[i]+=step[i];
    }
    setTimeout(snow,timer);
    }


    function init(){
    winsize();
    for (i = 0; i < num; i++){
    theFlakes[i] = document.getElementById("flake"+(idx+i)).style;
    y[i] = Math.round(Math.random()*h);
    x[i] = Math.round(Math.random()*w);
    }
    snow();
    }


    if (window.addEventListener){
    window.addEventListener("resize",winsize,false);
    window.addEventListener("load",init,false);
    }
    else if (window.attachEvent){
    window.attachEvent("onresize",winsize);
    window.attachEvent("onload",init);
    }

    })();
    }//End.






    RICHIAMATO DALLA PAGINA html:


    <script type="text/javascript" src="http://sito.org/_altervista_ht/snow.js"></script>



    tuttavia dopo aver applicato il codice, l'effetto neve ce l'ho sulla pagina INTERA mentre io lo vorrei solo limitato ad una tabella, è fattibile

    esempio tabella sul quale vorrei applicare l'effetto neve :

    <table width="450" height="200" border="1">
    <tr>
    <td></td>
    </tr>
    </table>

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    541
    per farla più breve.... volevo sapere se si può DELIMITARE l'effetto neve solo all'interno di una tabella anzichè a tutta la pagina html....

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    541
    non si può ? :master:

  4. #4
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Originariamente inviato da fasa
    non si può ? :master:
    Si può fare, ma dovresti riscrivere quasi tutto il codice, un lavoraccio farlo, e difficile da spiegare, ti auguro di risolvere ma ne dubito.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  5. #5
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    541
    io ho trovato pure questo codice , potrebbe essere utile?

    <script language="text/javascript">
    function immagine_variabile(){
    document.getElementById('http://sito/_altervista_ht/snow.js').style.display="block">);
    }
    </script>

  6. #6
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    No, non conosci il javascript andare a tentoni e inutile, l'unica cosa (molto difficile) e trovare su google un script che faccia al caso tuo, con ricerche incrociate oppure rinuncia.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

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.