2011-12-08 32 views
-1

我有一个网站的雪的脚本,我从this site。正如你所看到的,雪不会进入页面底部。我怎样才能让它走到底部?直到页面结尾处的积雪

的源代码:

var SNOW_Time; 
var SNOW_dx, SNOW_xp, SNOW_yp; 
var SNOW_am, SNOW_stx, SNOW_sty; 
var i, SNOW_Browser_Width = $(document).width(), SNOW_Browser_Height = $(document).height(); 

SNOW_dx = new Array(); 
SNOW_xp = new Array(); 
SNOW_yp = new Array(); 
SNOW_am = new Array(); 
SNOW_stx = new Array(); 
SNOW_sty = new Array(); 

for (i = 0; i < SNOW_no; ++i) { 
    SNOW_dx[i] = 0; 
    SNOW_xp[i] = Math.random() * (SNOW_Browser_Width - 50); 
    SNOW_yp[i] = Math.random() * SNOW_Browser_Height; 
    SNOW_am[i] = Math.random() * 20; 
    SNOW_stx[i] = 0.02 + Math.random()/10; 
    SNOW_sty[i] = 0.7 + Math.random(); 
    if (i == 0) document.write("<\div id=\"SNOW_flake" + i + "\" style=\"position: absolute; z-index: " + i + "; visibility: visible; top: 15px; left: 15px; width: " + SNOW_Width + "; height: " + SNOW_Height + "; background: url('" + SNOW_Picture + "') no-repeat;\"><\/div>"); 
    else document.write("<\div id=\"SNOW_flake" + i + "\" style=\"position: absolute; z-index: " + i + "; visibility: visible; top: 15px; left: 15px; width: " + SNOW_Width + "; height: " + SNOW_Height + "; background: url('" + SNOW_Picture + "') no-repeat;\"><\/div>"); 
} 

function SNOW_Weather() { 

    for (i = 0; i < SNOW_no; ++i) { 
     SNOW_yp[i] += SNOW_sty[i]; 

     if (SNOW_yp[i] > SNOW_Browser_Height) { 
      SNOW_xp[i] = Math.random() * (SNOW_Browser_Width - SNOW_am[i] - 30); 
      SNOW_yp[i] = 0; 
      SNOW_stx[i] = 0.02 + Math.random()/10; 
      SNOW_sty[i] = 0.7 + Math.random(); 
     } 

     SNOW_dx[i] += SNOW_stx[i]; 

     document.getElementById("SNOW_flake" + i).style.top = SNOW_yp[i] + "px"; 
     document.getElementById("SNOW_flake" + i).style.left = SNOW_xp[i] + SNOW_am[i] * Math.sin(SNOW_dx[i]) + "px"; 
    } 

    SNOW_Time = setTimeout("SNOW_Weather()", 10); 

} 

SNOW_Weather(); 
+0

我看你有没有接受我的答案。有没有想让我补充的东西让你满意? –

+1

对不起,不小心碰到了按钮...... :) –

+0

哈哈谢谢,我在想知道它有什么问题:) –

回答

1

它看起来像它是由可变SNOW_Browser_Height确定。 $(document).height()不会返回适当的高度。你可以用这个代替:

document.body.getClientRects()[0].height 
+0

谢谢你的回复!一切正常。 –

+0

@MaksudAbdurahmanov欢迎来到Stack Overflow。如果答案解决了您的问题,您可以点击旁边的复选标记将其标记为已接受的答案。 –