View Full Version : Turning on/off the falling snow effect

11-09-2005, 05:21 PM
I am looking at using the Snow Effect without images on my Christmas site but I would like to include a link to turn on/off the effect.
I would like it on as default but offer the user the option to turn it off if they find it annoying.
Can anyone help me out?
Thanks :)

11-09-2005, 08:25 PM
.. In this case, link is: http://www.dynamicdrive.com/dynamicindex3/snow.htm

Sure, to create such a link, first, locate the line inside the script:

snowtimer=setTimeout("snowIE_NS6()", 10);

The part in red needs to be added into the original code.

Then, add the below extra code to the script:

function hidesnow(){
if (window.snowtimer){
for (i = 0; i < no; ++ i)

Finally, in your HTML, create the link to hide the snow effect:

<a href="javascript: hidesnow()">Hide snow</a>

11-09-2005, 09:31 PM
.. In this case, link is: http://www.dynamicdrive.com/dynamicindex3/snow.htm

Another good reason to supply the link to the script - unless I am mistaken, the OP is using the snow without images script not the one with images you just so artfully answered his question for. Don't feel bad, I've been doing a bit of that lately. Also the OP wanted, I think, to be able to turn it back on. I came up with this mod of the snow.js file that comes with 'Snow Effect without images' - at the very end of snow.js where it looks like so:


Make it like so (additions red):

function setFlakes(el){
var val=el.value? el.value : el.innerHTML
var hf=document.getElementsByTagName('div')
for (var i_tem = 0; i_tem < hf.length; i_tem++)
if (hf[i_tem].id.indexOf('flake')!==-1)
hf[i_tem].style.display=val=="Stop Snow"? 'none' : ''
el.value=val=="Stop Snow"? 'Start Snow' : 'Stop Snow'
el.innerHTML=val=="Stop Snow"? 'Start Snow' : 'Stop Snow'

Then put this link on your page:

<a href="#" onclick="setFlakes(this);return false;">Stop Snow</a>

OR this snazzy button (don't use both):

<input id="control" type="button" value="Stop Snow" onclick="setFlakes(this);">

11-10-2005, 09:53 AM
Thanks very much, sorry I forgot to put the link in!
I'll remember in the future.
Thank you to both of you for your help!

11-10-2005, 10:33 AM
Hehe you're right jscheuer1. Now, should I feel stupid or upset at providing a solution to a non existent question? :D