Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Troy297's Avatar
    Join Date
    Oct 2006
    Location
    Earth
    Posts
    314
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question Why Isn't This Working?

    Hey All,

    I am trying to get a snowflake effect on my website. It worked on the actual content pages but not on the "welcome/enter" page.... any reason why & how I can get it to work? Code below.

    snow.js = http://www.quickscriptz.uni.cc/v2/snow.js

    index.php
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title><?php require('v2/title.php');?></title>
    <META name="verify-v1" content="My-Google-Webtools-Verification-Code-Hidden" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <?php require('v2/meta.php');?>
    </head>
    <body bgcolor="#5A5A5A">
    
    <script language=JavaScript src="v2/snow.js"></script>
    
    <center>
    
    <div align="center" style="position: absolute; align: center; display: none;">
    <a href="http://www.uni.cc/" target="_blank"><img src="http://www.uni.cc/site/ext_imgreflogo.php" border="0" onLoad="this.width=57;this.height=20;" width="1" height="1" alt="Register your domain name and build your site at UNI.CC"></a> 
    </div>
    <a href="v2/index.php" alt="Enter Site" title="Enter Site">
    <img src="v2/images/enter.gif" border="0" alt="Enter Site" title="Enter Site">
    </a>
    
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    _uacct = "UA-1024588-1";
    urchinTracker();
    </script>
    
    </center>
    
    </div>
    </body>
    </html>
    As you likely noticed the snow.js file is located in the "v2" folder, which is the correct link - I made sure of it.

    Any help would be greatly appreciated!

    Note - it works in IE but not Firefox? (http://www.quickscriptz.uni.cc/index.php)
    Last edited by Troy297; 01-01-2007 at 09:14 PM.
    Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
    Radio DJ Panel v3 - It's Here!

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Because the code is an old one, quite deprecated:
    - for modern browers (DOM compliant) the CSS size values must have a measurement units

    element.style.top=somevalue+'px';

    - In IE there is a difference in quirk mode vs compliant mode in calculating the document's size. In quirk mode (IE 5, or IE 6+ without a DOCTYPE), the "volume" of the document is given by document.body. In compliant mode (IE6+ with a DOCTYPE), we are talking about document.documentElement

    - New versions of Opera are rather close now to the full compliant browsers (Gecko engine based on: Mozilla, FireFox, NS8), thus they use window.innerHeight and window.innerWidth as document's "volume" size.

    Here's a quick modified variant of that code. I don't know if it is full cross browser, but I was tested and it works for FireFox 2.0, IE 6.02, Opera 9.1 under XP/SP2.
    Code:
    // CREDITS:
    // Snowmaker Copyright (c) 2003 Peter Gehrig. All rights reserved.
    // Distributed by http://www.**************
    // Permission given to use the script provided that this notice remains as is.
    // Modified 2007 for DOM compliant browsers by Kor corneliulucian[at]gmail.com
    // Set the number of snowflakes (more than 30 - 40 not recommended)
    var snowmax=40
    
    // Set the colors for the snow. Add as many colors as you like
    var snowcolor=new Array("#aaaacc","#ddddFF","#ccccDD")
    
    // Set the fonts, that create the snowflakes. Add as many fonts as you like
    var snowtype=new Array("Arial Black","Arial Narrow","Times","Comic Sans MS")
    
    // Set the letter that creates your snowflake (recommended:*)
    var snowletter="*"
    
    // Set the speed of sinking (recommended values range from 0.3 to 2)
    var sinkspeed=0.9
    
    // Set the maximal-size of your snowflaxes
    var snowmaxsize=28
    
    // Set the minimal-size of your snowflaxes
    var snowminsize=8
    
    // 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
    
    ///////////////////////////////////////////////////////////////////////////
    // CONFIGURATION ENDS 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 ie=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
    var ns_moz=document.getElementById&&!document.all
    var opera=browserinfos.match(/Opera/)  
    var browserok=ie||ns_moz||opera
    
    function randommaker(range) {		
    	rand=Math.floor(range*Math.random())
        return rand
    }
    
    function initsnow() {
    	if (ie) {
    	
    		if(document.documentElement){
    		marginbottom = document.documentElement.clientHeight
    		marginright = document.documentElement.clientWidth
    		}
    		else if(document.body){
    		marginbottom = document.body.clientHeight
    		marginright = document.body.clientWidth
    		}
    	}
    	else if (ns_moz|| opera) {
    		marginbottom = window.innerHeight
    		marginright = window.innerWidth
    	}
    	var snowsizerange=snowmaxsize-snowminsize;
    	for (var i=0;i<=snowmax;i++) {
    		crds[i] = 0;                      
        	lftrght[i] = Math.random()*15;         
        	x_mv[i] = 0.03 + Math.random()/10;
    		snow[i]=document.getElementById("s"+i)
    		snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)]
    		snow[i].size=randommaker(snowsizerange)+snowminsize;
    		snow[i].style.fontSize=snow[i].size+'px'
    		snow[i].style.color=snowcolor[randommaker(snowcolor.length)]
    		snow[i].sink=sinkspeed*snow[i].size/5
    		if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
    		if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
    		if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
    		if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
    		snow[i].posy=randommaker(6*marginbottom-marginbottom-6*snow[i].size)
    		snow[i].style.left=snow[i].posx+'px'
    		snow[i].style.top=snow[i].posy+'px'
    	}
    	movesnow()
    }
    
    function movesnow() {
    	for (var i=0;i<=snowmax;i++) {
    		crds[i] += x_mv[i];
    		snow[i].posy+=snow[i].sink
    		snow[i].style.left=(snow[i].posx+lftrght[i]*Math.sin(crds[i]))+'px';
    		snow[i].style.top=(snow[i].posy)+'px';
    		
    		if (snow[i].posy>=marginbottom-6*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){
    			if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
    			if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
    			if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
    			if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
    			snow[i].posy=0
    		}
    	}
    	var timer=setTimeout("movesnow()",50)
    }
    
    for (var i=0;i<=snowmax;i++) {
    	document.write('<span id="s'+i+'" style="position:absolute;top:-'+snowmaxsize+'px">'+snowletter+'</span>');
    }
    if (browserok) {
    	window.onload=initsnow
    }
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Regular Coder Troy297's Avatar
    Join Date
    Oct 2006
    Location
    Earth
    Posts
    314
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Thanks for the reply! I tried the code and it is now working!

    +1 Rep
    Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
    Radio DJ Panel v3 - It's Here!


  •  

    Posting Permissions

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