Results 1 to 7 of 7

Thread: snow effect not working in FF

  1. #1
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default snow effect not working in FF

    1) Script Title: Snow with no images

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ownoimages.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.
    Last edited by alexloony; 11-27-2007 at 09:44 PM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,140
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.

    Edit:
    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:

    Code:
    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:

    Code:
    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; 
    }
    }
    Last edited by jscheuer1; 11-28-2007 at 08:30 AM. Reason: add FF 'height solution'
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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! 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!

  5. #5
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    okay. one more mistake.... when I'm adding more flakes to that script.... in IE it works, in FF it doesnt. Help?

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    if (d.documentElement.style && 
    typeof d.documentElement.style.MozOpacity == "string")
    num = 12;
    If you remove it or comment it out:

    Code:
    /*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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh. Than a lot! I won't use it... My friend will use it xD So that's... his problems! Thnx a lot

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •