Quote:
Originally Posted by Darat
I've just tried the code from http://www.dynamicdrive.com/dynamicindex3/snow.htm .
The code seems to be fine, I put it in the headerinclude template and it is inserted into my forum pages, but it displays just one snowflake at the top left. If I use "preview" from the template manager it shows it working with moving snowflakes.
Anyone know why it won't work with a vBulletin forum page?
|
Are you using firefox, by any chance?
Try this:
PHP Code:
//Configure below to change URL path to the snow image
var SnowPicture = "http://www.yourdomain.com/forum/images/misc/snow.gif"
var no = 10;
var browser_IE_NS = (document.body.clientHeight) ? 1 : 0;
var browser_MOZ = (self.innerWidth) ? 1 : 0;
var SnowTime;
var dx, xp, yp;
var am, stx, sty;
var i, Browser_Width, Browser_Height;
if (browser_IE_NS)
{
Browser_Width = document.body.clientWidth;
Browser_Height = document.body.clientHeight;
}
else if (browser_MOZ)
{
Browser_Width = self.innerWidth - 20;
Browser_Height = self.innerHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
for (i = 0; i < no; ++ i)
{
dx[i] = 0;
xp[i] = Math.random()*(Browser_Width-50);
yp[i] = Math.random()*Browser_Height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
document.write("<\div id=\"snowflake"+ i +"\" style=\"position: absolute; z-index: "+ i +"; visibility: visible; top: 15px; left: 15px;\"><\img src='"+SnowPicture+"' border=\"0\"><\/div>");
}
function SnowWeather()
{
for (i = 0; i < no; ++ i)
{
yp[i] += sty[i];
if (yp[i] > Browser_Height-50)
{
xp[i] = Math.random()*(Browser_Width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
}
dx[i] += stx[i];
document.getElementById("snowflake"+i).style.top=yp[i]+"px";
document.getElementById("snowflake"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";
}
SnowTime = setTimeout("SnowWeather()", 10);
}
SnowWeather();
</script>
(Copy that over everything from the path to snow.gif down.)