PDA

View Full Version : snow effect not working in FF



alexloony
11-27-2007, 09:10 PM
1) Script Title: Snow with no images

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex3/snownoimages.htm

3) Describe problem: I have skinned website. So... Everythjing is in headers and footers. In header I posted the script... it worsk in IE, but it not works in FF... what's the problem? my website: www.christieroad.net . and if I done it to simple html it works, but only in maybe after 20% of the window he disappears.

ddadmin
11-28-2007, 01:58 AM
Hmmm I've tried a few things, but couldn't get the effect to show up in FF either. It's probably something specific to your site's layout/CSS, but this is one of those legacy scripts that isn't exactly fully compatible with all the modern browsers.

jscheuer1
11-28-2007, 03:59 AM
I'm looking at this script. It appears extraordinarily well written compared to others of its age in the DD library. The code branching appears to be via method tests (the current preferred technique) as opposed to browser sniffing, which was once quite in vogue (but that is usually less 'future proof').

That said, there is some problem with the way it reacts under FF. It cannot seem to see the height of the window, seeing instead the height of the body element. A little tweaking of the code should be able to remedy that. When I get the chance, I will see if I can follow through on this idea, and if successful, report back.

However, you also seem to indicate that you are having a separate problem that arises from using the script as (or as part of) an include.

Generally it is best to try to avoid that sort of thing. The preferred method is to simply put the external script tag directly on each page that you wish to have use the script.


OK, I think I've got the solution to the problem of the height in FF (this has nothing to do with the include problem)

replace:


function winsize(){
var oh,sy,ow,sx,rh,rw;
if (domWw){
if (d.documentElement && d.defaultView &&
typeof d.defaultView.scrollMaxY == "number"){
oh = d.documentElement.offsetHeight;
sy = d.defaultView.scrollMaxY;
ow = d.documentElement.offsetWidth;
sx = d.defaultView.scrollMaxX;
rh = oh-sy;
rw = ow-sx;
}
else{
rh = r.innerHeight;
rw = r.innerWidth;
}
h = rh - 2;
w = rw - 2;
}
else{
h = r.clientHeight - 2;
w = r.clientWidth - 2;
}
}

with:


function winsize(){
var oh,sy,ow,sx,rh,rw;
if (domWw){
if (d.documentElement && d.defaultView &&
typeof d.defaultView.scrollMaxY == "number"){
oh = d.documentElement.offsetHeight;
sy = d.defaultView.scrollMaxY;
ow = d.documentElement.offsetWidth;
sx = d.defaultView.scrollMaxX;
if(typeof d.documentElement.clientHeight == "number" && r.innerHeight-d.documentElement.clientHeight==17)
rh = d.documentElement.clientHeight;
else if(typeof d.documentElement.clientHeight == "number" && d.documentElement.clientHeight > r.innerHeight)
rh = oh-sy;
else rh=r.innerHeight;
rw = ow-sx;
}
else{
rh = r.innerHeight;
rw = r.innerWidth;
}
h = rh - 2;
w = rw - 2;
}
else{
h = r.clientHeight - 2;
w = r.clientWidth - 2;
}
}

alexloony
11-28-2007, 12:42 PM
Okay. Thnx a lot for problem solution on snow falling trough all the window. It really helped.
And for my problem I was thinking all the night and I understood what's the problem:
my all files looks like:
<? include(header.php) ?>
pages text
<? include(footer.php) ?>

So.. If I'll post my script in my body beginning, it won't work, 'cause my headers body is only this:

<body>
<img src="http://www.christieroad.net/skins/3/main2.png" width="800" height="713" />
<div style="position: absolute; top: 586px; left: 147px; width: 392px; height: 719px" border="0">

So that snow wil fall until that div will start. So solution is to put this script at bodys end. And it worked out! :D woohoo!

and maybe someone knows (or maybe can do it), how to do, that snow wont disappear at the windows bottom? that some line of snow would be there. Thnx a lot! :)

alexloony
12-02-2007, 09:50 PM
okay. one more mistake.... when I'm adding more flakes to that script.... in IE it works, in FF it doesnt. Help? :D

jscheuer1
12-03-2007, 06:41 AM
Not really a mistake this time. When this script was written, Mozilla based browsers (like FF today, NS 6 was the one at that time) were notoriously slow at doing the repetitive math required for these type of scripts. This code was used to limit the number of 'flakes' to 12 in those browsers:


if (d.documentElement.style &&
typeof d.documentElement.style.MozOpacity == "string")
num = 12;

If you remove it or comment it out:


/*if (d.documentElement.style &&
typeof d.documentElement.style.MozOpacity == "string")
num = 12;*/

That limitation will be removed. Worked fine on my FF 1.0.0.11 with a fast processor and 130 'flakes'. Some folks may have problems though. Try to use as few 'flakes' as possible to get your desired effect.

alexloony
12-03-2007, 08:32 AM
Oh. Than a lot! :) I won't use it... My friend will use it xD So that's... his problems! :D Thnx a lot :)