Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Snow Java Problem

    Can anyone please tell me why this script does not run please, thanks in advance

    <body>
    <script src="snow.js" type="text/javascript">
    </script> <img src="06_xmas.gif" width="480" height="160" />
    <script type="text/javascript">
    startSnow();
    </script>
    </body>
    If you are a fool at forty, you will always be a fool

  2. #2
    Silver Lounger Banyarola's Avatar
    Join Date
    Dec 2009
    Location
    Big Indian, New York
    Posts
    1,854
    Thanks
    7
    Thanked 63 Times in 52 Posts
    Copy and paste this script.
    I use it and it doesn't require any images.

    <SCRIPT type="text/javascript">
    /*
    Snow Fall 1 - no images - Java Script
    Visit http://rainbow.arch.scriptmania.com/scripts/
    for this script and many more
    */

    // NOTE: Lots of large, fast moving snowflakes will use a lot of system resources.

    // Set the number of snowflakes (more than 30 - 40 not recommended)
    var snowmax=30

    // Set the color of the snow.
    var snowcolor=new Array("white")

    // Set the font that creates the snowflakes.
    var snowtype=new Array("Arial")

    // Set the character that creates your snowflake.
    var snowletter="*"

    // Set the speed of sinking (recommended values range from 0.3 to 2)
    var sinkspeed=.75

    // Set the maximum size of your snowflakes
    var snowmaxsize=30

    // Set the minimal size of your snowflakes
    var snowminsize=12

    // Set the snowing-zone
    // Set 1 for all-over-snowing, set 2 for left-side-snowing
    // Set 3 for center-snowing, set 4 for right-side-snowing
    var snowingzone=1

    /*
    // * NO CONFIGURATION BELOW HERE *
    */

    // Do not edit below this line
    var snow=new Array()
    var marginbottom
    var marginright
    var timer
    var i_snow=0
    var x_mv=new Array();
    var crds=new Array();
    var lftrght=new Array();
    var browserinfos=navigator.userAgent
    var ie5=document.all&&document.getElementById&&!browse rinfos.match(/Opera/)
    var ns6=document.getElementById&&!document.all
    var opera=browserinfos.match(/Opera/)
    var browserok=ie5||ns6||opera

    function randommaker(range) {
    rand=Math.floor(range*Math.random())
    return rand
    }

    function initsnow() {
    if (ie5 ||opera) {
    marginbottom = document.body.clientHeight-10
    marginright = 775
    }
    else if (ns6) {
    marginbottom = window.innerHeight-10
    marginright = 775
    }
    var snowsizerange=snowmaxsize-snowminsize
    for (iSnow=0;iSnow<=snowmax;iSnow++) {
    crds[iSnow] = 0;
    lftrght[iSnow] = Math.random()*15;
    x_mv[iSnow] = 0.03 + Math.random()/10;
    snow[iSnow]=document.getElementById("s"+iSnow)
    snow[iSnow].style.fontFamily=snowtype[randommaker(snowtype.length)]
    snow[iSnow].size=randommaker(snowsizerange)+snowminsize
    snow[iSnow].style.fontSize=snow[iSnow].size
    snow[iSnow].style.color=snowcolor[randommaker(snowcolor.length)]
    snow[iSnow].sink=sinkspeed*snow[iSnow].size/5
    if (snowingzone==1) {snow[iSnow].posx=randommaker(marginright-snow[iSnow].size)}
    if (snowingzone==2) {snow[iSnow].posx=randommaker(marginright/2-snow[iSnow].size)}
    if (snowingzone==3) {snow[iSnow].posx=randommaker(marginright/2-snow[iSnow].size)+marginright/4}
    if (snowingzone==4) {snow[iSnow].posx=randommaker(marginright/2-snow[iSnow].size)+marginright/2}
    snow[iSnow].posy=randommaker(2*marginbottom-marginbottom-2*snow[iSnow].size)
    snow[iSnow].style.left=snow[iSnow].posx
    snow[iSnow].style.top=snow[iSnow].posy
    }
    movesnow()
    }

    function movesnow() {
    for (iSnow=0;iSnow<=snowmax;iSnow++) {
    crds[iSnow] += x_mv[iSnow];
    snow[iSnow].posy+=snow[iSnow].sink
    snow[iSnow].style.left=snow[iSnow].posx+lftrght[iSnow]*Math.sin(crds[iSnow]);
    snow[iSnow].style.top=snow[iSnow].posy

    if (snow[iSnow].posy>=marginbottom-2*snow[iSnow].size ||parseInt(snow[iSnow].style.left)>(marginright-3*lftrght[iSnow])){
    if (snowingzone==1) {snow[iSnow].posx=randommaker(marginright-snow[iSnow].size)}
    if (snowingzone==2) {snow[iSnow].posx=randommaker(marginright/2-snow[iSnow].size)}
    if (snowingzone==3) {snow[iSnow].posx=randommaker(marginright/2-snow[iSnow].size)+marginright/4}
    if (snowingzone==4) {snow[iSnow].posx=randommaker(marginright/2-snow[iSnow].size)+marginright/2}
    snow[iSnow].posy=0
    }
    }
    var timer=setTimeout("movesnow()",50)
    }

    for (iSnow=0;iSnow<=snowmax;iSnow++) {
    document.write("<span id='s"+iSnow+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>")
    }
    if (browserok) {
    window.onload=initsnow
    }
    </SCRIPT>
    "If You Are Reading This In English, Thank A VET"

  3. #3
    Silver Lounger Banyarola's Avatar
    Join Date
    Dec 2009
    Location
    Big Indian, New York
    Posts
    1,854
    Thanks
    7
    Thanked 63 Times in 52 Posts
    You can see it in action here: http://domdedomdom.com/Christmas_2011.html
    "If You Are Reading This In English, Thank A VET"

  4. #4
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,924
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks for this

    Braddy60
    If you are a fool at forty, you will always be a fool

  5. #5
    Silver Lounger Banyarola's Avatar
    Join Date
    Dec 2009
    Location
    Big Indian, New York
    Posts
    1,854
    Thanks
    7
    Thanked 63 Times in 52 Posts
    No problem.
    "If You Are Reading This In English, Thank A VET"

Posting Permissions

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