2011-12-08 2 views
-1

나는 눈이 내릴만한 스크립트가 있는데, 나는 this site에서 가져 갔다. 보시다시피, 눈은 페이지의 맨 아래로 가지 않습니다. 어떻게하면 바닥으로 갈 수 있습니까?눈이 내릴 때까지

소스 코드 :이 변수 SNOW_Browser_Height에 의해 결정처럼

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

것 같습니다. $(document).height()이 적절한 높이를 반환하지 않습니다. 대신 다음을 사용할 수 있습니다.

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

답장을 보내 주셔서 감사합니다! 모든 것이 작동합니다. –

+0

@MaksudAbdurahmanov 환영합니다 스택 오버플로. 해답이 문제를 해결하면 그 옆에있는 체크 표시를 클릭하여 수락 된 답으로 표시 할 수 있습니다. –

관련 문제