Real Estate Forums

Coding HTML, ASP, PHP, JAVA MYSQL and more. All coding questions should be asked here.

Reply
 
Thread Tools Display Modes
Old 12-11-2004, 09:02 PM
kyle422's Avatar
kyle422 kyle422 is offline
Real Estate Webmaster
 
Join Date: Oct 2004
Location: Florida
Posts: 2,109
kyle422 is on a distinguished road
Default cool holiday script for you guys

This is a cool script for slowly falling snow flakes.

####begin script#####
<SCRIPT language=JavaScript1.2>



var snowsrc="images/snow.gif"
var no = 6;

var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;

var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;

if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}

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()*(doc_width-50);
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {
document.write("<layer name='dot"+ i +"' left='15' top='15' visibility='show'><img src='"+snowsrc+"' border='0'></a></layer>");
} else {
document.write("<layer name='dot"+ i +"' left='15' top='15' visibility='show'><img src='"+snowsrc+"' border='0'></layer>");
}
} else if (ie4up) {
if (i == 0) {
document.write("<div id='dot"+ i +"' style='POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;'><img src='"+snowsrc+"' border='0'></a></div>");
} else {
document.write("<div id='dot"+ i +"' style='POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;'><img src='"+snowsrc+"' border='0'></div>");
}
}
}

function snowNS() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowNS()", 20);
}

function snowIE() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx[i] += stx[i];
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowIE()", 20);
}

if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}

</SCRIPT>
####end script####

Last edited by kyle422 : 12-14-2005 at 06:17 PM.
Reply With Quote
Old 12-12-2004, 12:28 AM
sarahk's Avatar
sarahk sarahk is offline
Uber Real Estate Webmaster
 
Join Date: Jun 2004
Location: Auckland, New Zealand
Posts: 593
sarahk is on a distinguished road
Send a message via ICQ to sarahk Send a message via AIM to sarahk Send a message via Yahoo to sarahk
Default Re: cool holiday script for you guys

it snows in Florida at Xmas? I thought your Xmas would be like ours...
Attached Images
 
Reply With Quote
Old 12-12-2004, 03:11 AM
Vlado Tovarnak's Avatar
Vlado Tovarnak Vlado Tovarnak is offline
Real Estate WebMaster
 
Join Date: Sep 2004
Location: Czech Republic
Posts: 159
Vlado Tovarnak is on a distinguished road
Send a message via ICQ to Vlado Tovarnak
Default Re: cool holiday script for you guys

This is shorter and should work with all browsers. I hope.

Code:
	<script type="text/javascript">
		var snowsrc = "snehova-vlocka.gif" // source of snowflake
		var no = 6; // no. of snowflakes
		var doc_width, doc_height;

		if (window.innerWidth || window.innerHeight)//opera Netscape 6 Netscape 4x Mozilla 
		{ 
			doc_width = window.innerWidth; 
			doc_height = window.innerHeight; 
		} 

		if (document.body.clientWidth || document.body.clientHeight)//IE Mozilla 
		{ 
			doc_width = document.body.clientWidth; 
			doc_height = document.body.clientHeight; 
		} 

		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() * (doc_width - 50);
			yp[i] = Math.random() * doc_height;
			am[i] = Math.random() * 20;
			stx[i] = 0.02 + Math.random()/10;
			sty[i] = 0.7 + Math.random();
			
			document.write("<div id='dot"+ i +"' style='POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;'><img src='"+snowsrc+"' border='0'></div>");

		}

		function snow(doc_width, doc_height)
		{
			for (i = 0; i < no; ++ i)
			{
				sflake = new Array();
				sflake[i] = document.getElementById('dot'+i); // getting all snowflakes
				yp[i] += sty[i];
				if ( yp[i] > doc_height - 50 )
				{
					xp[i] = Math.random()*(doc_width-am[i]-30);
					yp[i] = 0;
					stx[i] = 0.02 + Math.random()/10;
					sty[i] = 0.7 + Math.random();
				}
				dx[i] += stx[i];

				sflake[i].style.top = yp[i] + 'px';
				sflake[i].style.left = xp[i] + am[i] * Math.sin(dx[i]) + 'px';
			}
			setTimeout("snow(doc_width, doc_height)", 20);
		}

                 snow(doc_width, doc_height);
	</script>
__________________
Vlado Tovarnak

"The more I want to get something done, the less I call it work."
"In order to win, you must expect to win."

by RICHARD BACH


http://www.ValuesGuide.com is now producing and providing leads for real estate agents
Reply With Quote
Old 12-12-2004, 08:21 AM
ResaleBroker's Avatar
ResaleBroker ResaleBroker is offline
Real Estate Webmaster
 
Join Date: Jun 2004
Posts: 4,727
ResaleBroker is on a distinguished road
Default Re: cool holiday script for you guys

Nice Script.

Vlado, that worked fine in IE6, Netscape 7.2, Opera 7.5, and Firefox.
Reply With Quote
Old 12-12-2004, 09:25 AM
kyle422's Avatar
kyle422 kyle422 is offline
Real Estate Webmaster
 
Join Date: Oct 2004
Location: Florida
Posts: 2,109
kyle422 is on a distinguished road
Default Re: cool holiday script for you guys

Quote:
Originally Posted by sarahk
it snows in Florida at Xmas? I thought your Xmas would be like ours...
Yes, the snow is not very fitting for Florida or my site, but I figured I have to have something to celebrate the holidays.
Reply With Quote
Old 12-13-2004, 05:00 AM
CafeMonkey's Avatar
CafeMonkey CafeMonkey is offline
Real Estate Web Guru
 
Join Date: Nov 2004
Location: Richmond, VA
Posts: 274
CafeMonkey is on a distinguished road
Default Re: cool holiday script for you guys

Way cool!

I wanted to do something, but didn't want to turn into a "Christmas" template...

Thank you... Thank you...

PS... Kyle... You should put a lit-up palm tree on your site, like the Corona commercial! That's always cool!

Last edited by CafeMonkey : 12-13-2004 at 05:04 AM.
Reply With Quote
Old 12-13-2004, 07:33 AM
kyle422's Avatar
kyle422 kyle422 is offline
Real Estate Webmaster
 
Join Date: Oct 2004
Location: Florida
Posts: 2,109
kyle422 is on a distinguished road
Default Re: cool holiday script for you guys

Quote:
Originally Posted by CafeMonkey
PS... Kyle... You should put a lit-up palm tree on your site, like the Corona commercial! That's always cool!
That would be quite funny.
Kyle
Reply With Quote
Old 12-13-2004, 06:48 PM
kyle422's Avatar
kyle422 kyle422 is offline
Real Estate Webmaster
 
Join Date: Oct 2004
Location: Florida
Posts: 2,109
kyle422 is on a distinguished road
Default Re: cool holiday script for you guys

Quote:
Originally Posted by CafeMonkey
Way cool!

I wanted to do something, but didn't want to turn into a "Christmas" template...

Thank you... Thank you...

PS... Kyle... You should put a lit-up palm tree on your site, like the Corona commercial! That's always cool!
I noticed that you use the script that Vlado put up, which I couldn't get to work properly. It is also funky looking on your site. Have you looked at it?
Reply With Quote
Old 12-14-2004, 07:34 AM
CafeMonkey's Avatar
CafeMonkey CafeMonkey is offline
Real Estate Web Guru
 
Join Date: Nov 2004
Location: Richmond, VA
Posts: 274
CafeMonkey is on a distinguished road
Default Re: cool holiday script for you guys

Funky looking in what way? In what browser?

I just copied the script as he put it up, and copied the snowflake file.
Reply With Quote
Old 12-14-2004, 07:40 AM
ResaleBroker's Avatar
ResaleBroker ResaleBroker is offline
Real Estate Webmaster
 
Join Date: Jun 2004
Posts: 4,727
ResaleBroker is on a distinguished road
Default Re: cool holiday script for you guys

That does look a little different. Check out how the snowflakes float down the page on Kyle's site.

On your page the snowflakes stop right after they start giving the impression of "blinking."
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

For our members

Main Sections

IDX Coverage Areas

Spiders Welcome

All times are GMT -7. The time now is 02:28 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.