By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,181 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

How Do I Change to OnClick?

P: n/a
Hi - There's a neat little snowfall effect at
http://javascript.internet.com/bgeffects/snow.html. I want to use it for a
school project, but I need to run it by clicking on a button, rather than
when the page loads. In the HTML, I want to use something like:

<FORM>
<INPUT TYPE="button" value="Winter Time" onClick="?????">
</FORM>

but I cannot figure out what to do with the actual script to make this work.
I'd appreciate any suggestions. BTW, I'm a serious novice, so please keep it
as simple as possible. Thank you.
Jenny
Sep 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ASM
Jenny wrote:
Hi - There's a neat little snowfall effect at
http://javascript.internet.com/bgeffects/snow.html. I want to use it for a
school project, but I need to run it by clicking on a button, rather than
when the page loads. In the HTML, I want to use something like:
you delete :

if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}

from the script

and enter it in your onclick

onclick="if(ns4up) snowNS(); else if(ie4up) snowIE();"

<FORM>
<INPUT TYPE="button" value="Winter Time" onClick="?????">
</FORM>

but I cannot figure out what to do with the actual script to make this work.
I'd appreciate any suggestions. BTW, I'm a serious novice, so please keep it
as simple as possible. Thank you.
Jenny

--
Stephane Moriaux et son [moins] vieux Mac
Sep 19 '05 #2

P: n/a
"Jenny" <jw*********@earthlink.net> wrote in message
news:aR*******************@twister.southeast.rr.co m...
Hi - There's a neat little snowfall effect at
http://javascript.internet.com/bgeffects/snow.html. I want to use it for a
school project, but I need to run it by clicking on a button, rather than
when the page loads. In the HTML, I want to use something like:

<FORM>
<INPUT TYPE="button" value="Winter Time" onClick="?????">
</FORM>

but I cannot figure out what to do with the actual script to make this work. I'd appreciate any suggestions. BTW, I'm a serious novice, so please keep it as simple as possible. Thank you.
Jenny


Place this (exisiting) code in a function:

if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}

Then have a link invoke the function.

Such as:

function Snowflakes() {
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}
}

<a href="javascript:Snowflakes()">Snowflakes</a>

or

<img src="http://javascript.internet.com/img/snow/snow.gif"
border="0" width="24" height="24" onclick="Snowflakes()"
alt="Snowflakes" title="Snowflakes">
Sep 19 '05 #3

P: n/a

Jenny wrote:
Hi - There's a neat little snowfall effect at
http://javascript.internet.com/bgeffects/snow.html. I want to use it for a
school project, but I need to run it by clicking on a button, rather than
when the page loads. In the HTML, I want to use something like:

<FORM>
<INPUT TYPE="button" value="Winter Time" onClick="?????">
</FORM>

but I cannot figure out what to do with the actual script to make this work.
I'd appreciate any suggestions. BTW, I'm a serious novice, so please keep it
as simple as possible. Thank you.
Jenny


Hi Jenny,

I'm going to assume you followed the exact instructions as that site
told you.
Secondly, towards the end of the code you should see the following
lines:

if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}

Replace those lines with the following:

function startSnow()
{
if(ns4up)
snowNS();
else if(ie4up)
snowIE();
}

Finally, in your HTML you can do what you wanted:

<input type = "button" value = "Winter Time" onClick = "startSnow()"/>

Hope this helps :)

Sep 19 '05 #4

P: n/a
"Jenny" <jw*********@earthlink.net> wrote in message
news:aR*******************@twister.southeast.rr.co m...
Hi - There's a neat little snowfall effect at
http://javascript.internet.com/bgeffects/snow.html. I want to use it for a
school project, but I need to run it by clicking on a button, rather than
when the page loads. In the HTML, I want to use something like:

<FORM>
<INPUT TYPE="button" value="Winter Time" onClick="?????">
</FORM>

but I cannot figure out what to do with the actual script to make this
work. I'd appreciate any suggestions. BTW, I'm a serious novice, so please
keep it as simple as possible. Thank you.
Jenny


Thanks to everyone for your help. It worked great! Thanks again, Jenny
Sep 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.