It’s Christmas. It’s time for snowing. Want to have a snowfall on your site just like in my blog. Here’s the Java script for snowing.
Note – This code is for websites. Code for blogger is below this code
Note – This code is for websites. Code for blogger is below this code
<blockquote class="tr_bq">
<p>
<script><br /> //Configure below to change URL path to the snow image<br /> var snowsrc="http://subins.hp.af.cm/files/images/snow.gif"<br /> // Configure below to change number of snow to render<br /> var no = 20;<br /> // Configure whether snow should disappear after x seconds (0=never):<br /> var hidesnowtime = 0;<br /> // Configure how much snow should drop down before fading ("windowheight" or "pageheight")<br /> var snowdistance = "pageheight";<br />///////////Stop Config//////////////////////////////////<br /> var ie4up = (document.all) ? 1 : 0;<br /> var ns6up = (document.getElementById&&!document.all) ? 1 : 0;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>function iecompattest(){<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>}<br /> var dx, xp, yp; // coordinate and position variables<br /> var am, stx, sty; // amplitude and step variables<br /> var i, doc_width = 800, doc_height = 600;<br /> if (ns6up) {<br /> doc_width = self.innerWidth;<br /> doc_height = self.innerHeight;<br /> } else if (ie4up) {<br /> doc_width = iecompattest().clientWidth;<br /> doc_height = iecompattest().clientHeight;<br /> }<br /> dx = new Array();<br /> xp = new Array();<br /> yp = new Array();<br /> am = new Array();<br /> stx = new Array();<br /> sty = new Array();<br /> snowsrc=(snowsrc.indexOf("subins.hp.af.cm")!=-1)? "http://subins.hp.af.cm/files/images/snow.gif" : snowsrc<br /> for (i = 0; i < no; ++ i) { <br /> dx[i] = 0; // set coordinate variables<br /> xp[i] = Math.random()*(doc_width-50); // set position variables<br /> yp[i] = Math.random()*doc_height;<br /> am[i] = Math.random()*20; // set amplitude variables<br /> stx[i] = 0.02 + Math.random()/10; // set step variables<br /> sty[i] = 0.7 + Math.random(); // set step variables<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>if (ie4up||ns6up) {<br /> if (i == 0) {<br /> document.write("<div id="dot"+ i +"" style="POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;"><a href="http://sag-3.blogspot.com/2012/12/snowfall-using-js.html"><img src='"+snowsrc+"‘ border="0″></a></div>");<br /> } else {<br /> document.write("<div id="dot"+ i +"" style="POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;"><img src='"+snowsrc+"‘ border="0″></div>");<br /> }<br /> }<br /> }<br /> function snowIE_NS6() { // IE and NS6 main animation function<br /> doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")? iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;<br /> for (i = 0; i < no; ++ i) { // iterate for every dot<br /> yp[i] += sty[i];<br /> if (yp[i] > doc_height-50) {<br /> xp[i] = Math.random()*(doc_width-am[i]-30);<br /> yp[i] = 0;<br /> stx[i] = 0.02 + Math.random()/10;<br /> sty[i] = 0.7 + Math.random();<br /> }<br /> dx[i] += stx[i];<br /> document.getElementById("dot"+i).style.top=yp[i]+"px";<br /> document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px"; <br /> }<br /> snowtimer=setTimeout("snowIE_NS6()", 25);//Set Timeout<br /> }<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>function hidesnow(){<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>if (window.snowtimer) clearTimeout(snowtimer)<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>}<span class="Apple-tab-span" style="white-space: pre;"> </span>if (ie4up||ns6up){<br /> snowIE_NS6();<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>if (hidesnowtime>0)<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>setTimeout("hidesnow()", hidesnowtime*1000)<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>}<br /></script>
</p>
</blockquote>
Blogger Code
Go to Template -> Edit HTML
Paste this code after tag.