Code to stop snow on htm

W

Wayne-I-M

Hi

I got the code below from this forum - question can I get this to start
OnClick of something and then get it to stop OnClick of something else

Think I need to stop as it could be iritataing

many thanks

<html>
<body bgcolor="#228B22">
<style>
...drop { position: absolute; width: 3; filter: flipV(), flipH(); font-size:
40; color: blue }
</style>
<script language="javascript">
snow = true;
snowsym = " * "
rainsym = " ' "
howmany = 25
if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}
else{sym = rainsym; speed=50; drops=howmany; angle=6}
movex = -speed/angle; movey = speed; count = 0;

function moverain(){
for(move = 0; move < drops; move++){
xx[move]+=movex; yy[move]+=mv[move];
hmm = Math.round(Math.random()*1);
if(xx[move] < 0){xx[move] = maxx+10;}
if(yy[move] > maxy){yy[move] = 10;}
drop[move].left = xx[move]
drop[move].top = yy[move]+document.body.scrollTop;
}setTimeout('moverain()','1')}

</script>
<script language="javascript">

if (document.all){
drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()
ly = "document.all[\'"; st = "\'].style"
for(make = 0; make < drops; make++){
document.write('<div id="drop'+make+'" class=drop>'+sym+'</div>');
drop[make] = eval(ly+'drop'+make+st);
maxx = document.body.clientWidth-40
maxy = document.body.clientHeight-40
xx[make] = Math.random()*maxx;
yy[make] = -100-Math.random()*maxy;
drop[make].left = xx[make]
drop[make].top = yy[make]
mv[make] = (Math.random()*5)+speed/4;
drop[make].fontSize = (Math.random()*10)+20;
//*Change (col = 'white) to (col =YOUR COLOR)*//
if(snow){col = 'white'}else{col = 'blue'}
drop[make].color = col;
}
window.onload=moverain
}
</script>
</html>
 
W

Wayne-I-M

To follow on



The hide snow works fine
<p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>

Can someone tell me
why the show doesn't work ??
<p onclick="FP_callJS('FP_callJS()')"><a href="javascript:;">show</a></p>


Think I'm reference the wrong function

basically I don't want the code to run OnOpen but I would like it to run on
OnClick

Test page
http://www.folgarida.co.uk/snowtest.htm

many thanks if anyone can help
 
S

Stefan B Rusynko

You can't call a function from w/i a function
To stop it from running on start remove
window.onload=moverain

To start it use one function - say
<p onclick="moverain;"><a href="javascript:;">show</a></p>

Then to stop it use another function

<p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>




| To follow on
|
|
|
| The hide snow works fine
| <p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>
|
| Can someone tell me
| why the show doesn't work ??
| <p onclick="FP_callJS('FP_callJS()')"><a href="javascript:;">show</a></p>
|
|
| Think I'm reference the wrong function
|
| basically I don't want the code to run OnOpen but I would like it to run on
| OnClick
|
| Test page
| http://www.folgarida.co.uk/snowtest.htm
|
| many thanks if anyone can help
|
|
| --
| Wayne
| Trentino, Italia.
|
|
|
| "Wayne-I-M" wrote:
|
| > Hi
| >
| > I got the code below from this forum - question can I get this to start
| > OnClick of something and then get it to stop OnClick of something else
| >
| > Think I need to stop as it could be iritataing
| >
| > many thanks
| >
| > <html>
| > <body bgcolor="#228B22">
| > <style>
| > ..drop { position: absolute; width: 3; filter: flipV(), flipH(); font-size:
| > 40; color: blue }
| > </style>
| > <script language="javascript">
| > snow = true;
| > snowsym = " * "
| > rainsym = " ' "
| > howmany = 25
| > if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}
| > else{sym = rainsym; speed=50; drops=howmany; angle=6}
| > movex = -speed/angle; movey = speed; count = 0;
| >
| > function moverain(){
| > for(move = 0; move < drops; move++){
| > xx[move]+=movex; yy[move]+=mv[move];
| > hmm = Math.round(Math.random()*1);
| > if(xx[move] < 0){xx[move] = maxx+10;}
| > if(yy[move] > maxy){yy[move] = 10;}
| > drop[move].left = xx[move]
| > drop[move].top = yy[move]+document.body.scrollTop;
| > }setTimeout('moverain()','1')}
| >
| > </script>
| > <script language="javascript">
| >
| > if (document.all){
| > drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()
| > ly = "document.all[\'"; st = "\'].style"
| > for(make = 0; make < drops; make++){
| > document.write('<div id="drop'+make+'" class=drop>'+sym+'</div>');
| > drop[make] = eval(ly+'drop'+make+st);
| > maxx = document.body.clientWidth-40
| > maxy = document.body.clientHeight-40
| > xx[make] = Math.random()*maxx;
| > yy[make] = -100-Math.random()*maxy;
| > drop[make].left = xx[make]
| > drop[make].top = yy[make]
| > mv[make] = (Math.random()*5)+speed/4;
| > drop[make].fontSize = (Math.random()*10)+20;
| > //*Change (col = 'white) to (col =YOUR COLOR)*//
| > if(snow){col = 'white'}else{col = 'blue'}
| > drop[make].color = col;
| > }
| > window.onload=moverain
| > }
| > </script>
| > </html>
| >
| > --
| > Wayne
| > Trentino, Italia.
| >
 
W

Wayne-I-M

Hi Stefan

Thanks for getting back to me.

I have stepped through the code very carefully and can't find the
window.onload=moverain
or any other OnLoad

Also I can get the snow to stop but I can't work out work makes it start in
the 1st place so the
<p onclick="moverain;"><a href="javascript:;">show</a></p>
is also not working


--
Wayne
Trentino, Italia.



Stefan B Rusynko said:
You can't call a function from w/i a function
To stop it from running on start remove
window.onload=moverain

To start it use one function - say
<p onclick="moverain;"><a href="javascript:;">show</a></p>

Then to stop it use another function

<p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>




| To follow on
|
|
|
| The hide snow works fine
| <p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>
|
| Can someone tell me
| why the show doesn't work ??
| <p onclick="FP_callJS('FP_callJS()')"><a href="javascript:;">show</a></p>
|
|
| Think I'm reference the wrong function
|
| basically I don't want the code to run OnOpen but I would like it to run on
| OnClick
|
| Test page
| http://www.folgarida.co.uk/snowtest.htm
|
| many thanks if anyone can help
|
|
| --
| Wayne
| Trentino, Italia.
|
|
|
| "Wayne-I-M" wrote:
|
| > Hi
| >
| > I got the code below from this forum - question can I get this to start
| > OnClick of something and then get it to stop OnClick of something else
| >
| > Think I need to stop as it could be iritataing
| >
| > many thanks
| >
| > <html>
| > <body bgcolor="#228B22">
| > <style>
| > ..drop { position: absolute; width: 3; filter: flipV(), flipH(); font-size:
| > 40; color: blue }
| > </style>
| > <script language="javascript">
| > snow = true;
| > snowsym = " * "
| > rainsym = " ' "
| > howmany = 25
| > if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}
| > else{sym = rainsym; speed=50; drops=howmany; angle=6}
| > movex = -speed/angle; movey = speed; count = 0;
| >
| > function moverain(){
| > for(move = 0; move < drops; move++){
| > xx[move]+=movex; yy[move]+=mv[move];
| > hmm = Math.round(Math.random()*1);
| > if(xx[move] < 0){xx[move] = maxx+10;}
| > if(yy[move] > maxy){yy[move] = 10;}
| > drop[move].left = xx[move]
| > drop[move].top = yy[move]+document.body.scrollTop;
| > }setTimeout('moverain()','1')}
| >
| > </script>
| > <script language="javascript">
| >
| > if (document.all){
| > drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()
| > ly = "document.all[\'"; st = "\'].style"
| > for(make = 0; make < drops; make++){
| > document.write('<div id="drop'+make+'" class=drop>'+sym+'</div>');
| > drop[make] = eval(ly+'drop'+make+st);
| > maxx = document.body.clientWidth-40
| > maxy = document.body.clientHeight-40
| > xx[make] = Math.random()*maxx;
| > yy[make] = -100-Math.random()*maxy;
| > drop[make].left = xx[make]
| > drop[make].top = yy[make]
| > mv[make] = (Math.random()*5)+speed/4;
| > drop[make].fontSize = (Math.random()*10)+20;
| > //*Change (col = 'white) to (col =YOUR COLOR)*//
| > if(snow){col = 'white'}else{col = 'blue'}
| > drop[make].color = col;
| > }
| > window.onload=moverain
| > }
| > </script>
| > </html>
| >
| > --
| > Wayne
| > Trentino, Italia.
| >
 
S

Steve Easton

It's is at the very bottom of the page in code view
window.onload=moverain
}
</script>
</html>




Wayne-I-M said:
Hi Stefan

Thanks for getting back to me.

I have stepped through the code very carefully and can't find the
window.onload=moverain
or any other OnLoad

Also I can get the snow to stop but I can't work out work makes it start in
the 1st place so the
<p onclick="moverain;"><a href="javascript:;">show</a></p>
is also not working


--
Wayne
Trentino, Italia.



Stefan B Rusynko said:
You can't call a function from w/i a function
To stop it from running on start remove
window.onload=moverain

To start it use one function - say
<p onclick="moverain;"><a href="javascript:;">show</a></p>

Then to stop it use another function

<p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>




| To follow on
|
|
|
| The hide snow works fine
| <p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>
|
| Can someone tell me
| why the show doesn't work ??
| <p onclick="FP_callJS('FP_callJS()')"><a href="javascript:;">show</a></p>
|
|
| Think I'm reference the wrong function
|
| basically I don't want the code to run OnOpen but I would like it to run on
| OnClick
|
| Test page
| http://www.folgarida.co.uk/snowtest.htm
|
| many thanks if anyone can help
|
|
| --
| Wayne
| Trentino, Italia.
|
|
|
| "Wayne-I-M" wrote:
|
| > Hi
| >
| > I got the code below from this forum - question can I get this to start
| > OnClick of something and then get it to stop OnClick of something else
| >
| > Think I need to stop as it could be iritataing
| >
| > many thanks
| >
| > <html>
| > <body bgcolor="#228B22">
| > <style>
| > ..drop { position: absolute; width: 3; filter: flipV(), flipH(); font-size:
| > 40; color: blue }
| > </style>
| > <script language="javascript">
| > snow = true;
| > snowsym = " * "
| > rainsym = " ' "
| > howmany = 25
| > if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}
| > else{sym = rainsym; speed=50; drops=howmany; angle=6}
| > movex = -speed/angle; movey = speed; count = 0;
| >
| > function moverain(){
| > for(move = 0; move < drops; move++){
| > xx[move]+=movex; yy[move]+=mv[move];
| > hmm = Math.round(Math.random()*1);
| > if(xx[move] < 0){xx[move] = maxx+10;}
| > if(yy[move] > maxy){yy[move] = 10;}
| > drop[move].left = xx[move]
| > drop[move].top = yy[move]+document.body.scrollTop;
| > }setTimeout('moverain()','1')}
| >
| > </script>
| > <script language="javascript">
| >
| > if (document.all){
| > drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()
| > ly = "document.all[\'"; st = "\'].style"
| > for(make = 0; make < drops; make++){
| > document.write('<div id="drop'+make+'" class=drop>'+sym+'</div>');
| > drop[make] = eval(ly+'drop'+make+st);
| > maxx = document.body.clientWidth-40
| > maxy = document.body.clientHeight-40
| > xx[make] = Math.random()*maxx;
| > yy[make] = -100-Math.random()*maxy;
| > drop[make].left = xx[make]
| > drop[make].top = yy[make]
| > mv[make] = (Math.random()*5)+speed/4;
| > drop[make].fontSize = (Math.random()*10)+20;
| > //*Change (col = 'white) to (col =YOUR COLOR)*//
| > if(snow){col = 'white'}else{col = 'blue'}
| > drop[make].color = col;
| > }
| > window.onload=moverain
| > }
| > </script>
| > </html>
| >
| > --
| > Wayne
| > Trentino, Italia.
| >
 
W

Wayne-I-M

Many thanks to you both

I will spend the next ??? days trying to get this one to work - bit beyond
me but I'll try

http://www.schillmania.com/projects/snowstorm/

Happy christmas

--
Wayne
Trentino, Italia.



Steve Easton said:
It's is at the very bottom of the page in code view
window.onload=moverain
}
</script>
</html>




Wayne-I-M said:
Hi Stefan

Thanks for getting back to me.

I have stepped through the code very carefully and can't find the
window.onload=moverain
or any other OnLoad

Also I can get the snow to stop but I can't work out work makes it start in
the 1st place so the
<p onclick="moverain;"><a href="javascript:;">show</a></p>
is also not working


--
Wayne
Trentino, Italia.



Stefan B Rusynko said:
You can't call a function from w/i a function
To stop it from running on start remove
window.onload=moverain

To start it use one function - say
<p onclick="moverain;"><a href="javascript:;">show</a></p>

Then to stop it use another function

<p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>




| To follow on
|
|
|
| The hide snow works fine
| <p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>
|
| Can someone tell me
| why the show doesn't work ??
| <p onclick="FP_callJS('FP_callJS()')"><a href="javascript:;">show</a></p>
|
|
| Think I'm reference the wrong function
|
| basically I don't want the code to run OnOpen but I would like it to run on
| OnClick
|
| Test page
| http://www.folgarida.co.uk/snowtest.htm
|
| many thanks if anyone can help
|
|
| --
| Wayne
| Trentino, Italia.
|
|
|
| "Wayne-I-M" wrote:
|
| > Hi
| >
| > I got the code below from this forum - question can I get this to start
| > OnClick of something and then get it to stop OnClick of something else
| >
| > Think I need to stop as it could be iritataing
| >
| > many thanks
| >
| > <html>
| > <body bgcolor="#228B22">
| > <style>
| > ..drop { position: absolute; width: 3; filter: flipV(), flipH(); font-size:
| > 40; color: blue }
| > </style>
| > <script language="javascript">
| > snow = true;
| > snowsym = " * "
| > rainsym = " ' "
| > howmany = 25
| > if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}
| > else{sym = rainsym; speed=50; drops=howmany; angle=6}
| > movex = -speed/angle; movey = speed; count = 0;
| >
| > function moverain(){
| > for(move = 0; move < drops; move++){
| > xx[move]+=movex; yy[move]+=mv[move];
| > hmm = Math.round(Math.random()*1);
| > if(xx[move] < 0){xx[move] = maxx+10;}
| > if(yy[move] > maxy){yy[move] = 10;}
| > drop[move].left = xx[move]
| > drop[move].top = yy[move]+document.body.scrollTop;
| > }setTimeout('moverain()','1')}
| >
| > </script>
| > <script language="javascript">
| >
| > if (document.all){
| > drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()
| > ly = "document.all[\'"; st = "\'].style"
| > for(make = 0; make < drops; make++){
| > document.write('<div id="drop'+make+'" class=drop>'+sym+'</div>');
| > drop[make] = eval(ly+'drop'+make+st);
| > maxx = document.body.clientWidth-40
| > maxy = document.body.clientHeight-40
| > xx[make] = Math.random()*maxx;
| > yy[make] = -100-Math.random()*maxy;
| > drop[make].left = xx[make]
| > drop[make].top = yy[make]
| > mv[make] = (Math.random()*5)+speed/4;
| > drop[make].fontSize = (Math.random()*10)+20;
| > //*Change (col = 'white) to (col =YOUR COLOR)*//
| > if(snow){col = 'white'}else{col = 'blue'}
| > drop[make].color = col;
| > }
| > window.onload=moverain
| > }
| > </script>
| > </html>
| >
| > --
| > Wayne
| > Trentino, Italia.
| >
 
T

Trevor Lawrence

Stefan B Rusynko said:
You can't call a function from w/i a function
To stop it from running on start remove
window.onload=moverain

To start it use one function - say
<p onclick="moverain;"><a href="javascript:;">show</a></p>

Then to stop it use another function

<p onclick="FP_callJS('hidesnow()')"><a href="javascript:;">hide</a></p>

Stefan,

In a reply to a question of mine on scripting.jscript, I was advised
"Don't use the javascript pseudo-protocol. Ever."

I would much rather trust your advice, Stefan, but it is a topic that has
been discussed ad nauseam. I don't dare say "If it works, use it" because
that is not rigorous enough. <vbg>

On the other hand, <rhetorical>it does work.doesn't it ?</rhetorical>.

So also would
<p onclick="FP_callJS('hidesnow()')">hide</p>
This is a way to avoid the <a href="javascript:;"> method (protocol,
whatever), but has the disadvantage that there is no visual prompt, unless
one underlines the text.
<p onclick="FP_callJS('hidesnow()')"><u>hide</u></p>
OR
<button
style="text-decoration:underline;color:blue"
onmouseover="this.style.color='black'"
onmouseout="this.style.color='red'"
onclick="FP_callJS('hidesnow()')">hide</button>

which has 3 states similar to
a:link { color: blue; }
a:visited { color: red; }
a:hover { color: black; }

BTW,
1. One can call a function from within a function, but I assume that you
were referring to the particular context
2. Why use onclick="FP_callJS('hidesnow()')" ?
<non-rhetorical>
Wouldn't onclick="hidesnow()" work equally well ?
(Or better, given that the function FP_callJS may not be available - it
isn't to me.)
</non-rhetorical>
 
Top