Jump to content

Recommended Posts

Posted

Hi,

 

I was wondering if anyone would be kind enough to help me. Basically I am using the following script to create a snow effect:

 

 <br />
/*<br />
Snow Effect Script<br />
Created and submitted by Altan d.o.o. ([email protected], http://www.altan.hr/snow/index.html)<br />
Permission granted to Dynamicdrive.com to feature script in archive<br />
For full source code and installation instructions to this script, visit http://dynamicdrive.com<br />
*/<br />
<br />
<br />
//Configure below to change URL path to the snow image<br />
var snowsrc="https://vle.queenmaryshigh.walsall.sch.uk/user/74/118004.png"<br />
// Configure below to change number of snow to render<br />
var no = 5;<br />
<br />
var ns4up = (document.layers) ? 1 : 0; // browser sniffer<br />
var ie4up = (document.all) ? 1 : 0;<br />
<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 />
<br />
if (ns4up) {<br />
doc_width = self.innerWidth;<br />
doc_height = self.innerHeight;<br />
} else if (ie4up) {<br />
doc_width = document.body.clientWidth;<br />
doc_height = document.body.clientHeight;<br />
}<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 />
<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 />
if (ns4up) { // set layers<br />
if (i == 0) {<br />
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><a href=\"http://dynamicdrive.com/\"><img src='"+snowsrc+"' border=\"0\">");<br />
} else {<br />
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\">");<br />
}<br />
} else if (ie4up) {<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://dynamicdrive.com\"><img src='"+snowsrc+"' border=\"0\">");
} else {
document.write(""+snowsrc+"");
}
}
}

function snowNS() { // Netscape main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowNS()", 10);
}

function snowIE() { // IE main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx[i] += stx[i];
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowIE()", 10);
}

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

 

The problem is it only works properly in IE7, is it possible to change it to work with IE8, FireFox and Google Chrome?

 

Thanks to anyone who helps :o

 

Lee

Posted
This is the one iv used in the past, works with everything even safari and firefox!

plus can be changed to fairy lights (sorry!! i mean puff lanterns) very easily

 

 

 

Enjoy!

 

Hi, thanks for the script. I tried this but the website I'm using it on has a java menu and every time you put your mouse on the menu it causes the snow to freeze (no pun intended :p) and then it doesn’t continue to snow unless you refresh the page. Is there any way to get around this? It happens on all browsers :(

 

Thanks

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...