PDA

View Full Version : Running 2 Javascripts


kreitzberg00
6-26-02, 08:42 PM
I want to run these 2 scripts but I can't figure out how to modify the code. Can you please help!!

Script 1:

<SCRIPT LANGUAGE="JavaScript1.2">
<!--
//Original script by Altan (Snow@altan.hr), copyright 1999 Altan d.o.o.
// http://www.altan.hr/snow/index.html
// Modified by Paul Anderson, copyright 2001 CNET Builder.com

var snowflake = new Array();
snowflake[0]="single_small_star copy.gif";
snowflake[1]="single_small_star copy.gif";
snowflake[2]="single_small_star copy.gif";
snowflake[3]="single_small_star copy.gif";
snowflake[4]="single_small_star copy.gif";
snowflake[5]="single_small_star copy.gif";
snowflake[6]="single_small_star copy.gif";
snowflake[7]="single_small_star copy.gif";
snowflake[8]="single_small_star copy.gif";
var no = snowflake.length;
var speed = 7; // smaller numbers make the snow fall faster
var dx, xp, yp; // coordinate and position variables
var am, stx, sty; // amplitude and step variables
var obj, i, doc_width = 800, doc_height = 600;

function winSize() {
doc_width = window.innerWidth?window.innerWidth:document.body. clientWidth;
doc_height = window.innerHeight?window.innerHeight:document.bod y.clientHeight;
}

dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
winSize();
document.write("<STYLE type=\"text/css\">.flake {position:absolute;top:-200;}</STYLE>");
for (i = 0; i < no; i++) {
dx[i] = 0; // set coordinate variables
xp[i] = Math.random()*(doc_width-30) +10; // set position variables
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20; // set amplitude variables
stx[i] = 0.02 + Math.random()/10; // set step variables
sty[i] = 0.7 + Math.random(); // set step variables
document.write("<div id=\"dot"+ i +"\" class=\"flake\"><img src=\"");
document.write(snowflake[i] + "\" border=\"0\"></div>");
}

function snowMove(id,left,top) {
obj = document.getElementById?document.getElementById(id ).style:
document.all?document.all[id].style:
document.layers?document.layers[id]:null;
if (obj) {
obj.left=left;
obj.top=top;
}
}

function snow() {
winSize();
doc_scroll = (window.pageYOffset!=null)?window.pageYOffset:docu ment.body.scrollTop;
for (i = 0; i < no; ++ i) { // iterate for every dot
yp[i] += sty[i];
if (yp[i] > doc_height+doc_scroll-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = doc_scroll;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
}
dx[i] += stx[i];
snowMove("dot"+i,xp[i]+am[i]*Math.sin(dx[i]),yp[i]);
}
setTimeout("snow()", speed);
}

window.onload=snow;
// -->

</SCRIPT>

SCRIPT 2-



<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
redirTime = "9800";
redirURL = "http://www.flavapromotion.com/main.htm";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
// End -->
</script>


<body onLoad="redirTimer()">

RSaucier
6-26-02, 09:03 PM
Err...what is it you want to do to them?

Robert

alphadesk
6-26-02, 09:39 PM
Try this as your body tag and remove the window onload out of that script. you may have to try several different combinations till you get it to work.

<body onload="onLoad="redirTimer();window.onload=snow()">

You can get some more info here.

http://wsabstract.com/javatutors/multiplejava3.shtml

RSaucier
6-26-02, 09:55 PM
Alpha, you wearing that mind-reading hat again? :)

Robert

alphadesk
6-26-02, 11:10 PM
Yes :)

RoyW
6-27-02, 12:11 AM
Almost...

Remove the line
window.onload=snow;

Change your body tag to
<body onload="redirTimer();snow()">

alphadesk
6-27-02, 12:38 AM
Roy,

Glad you could make the party. We get lot's of javascript questions and by your site it's looks like you are just the person that will be able to help out in this area and many more.

Thanks

RoyW
6-27-02, 12:49 AM
Thanks alphadesk :)

This board and powhelp have really helped me with my powweb site so hopefully I can return tha favour.

(I notice the forum doesn't have a specific JavaScript or DHTML forum, wonder if they should create one?)

Cheers
Roy.

alphadesk
6-27-02, 01:02 AM
Roy,
I'll ask and see. This may not get high on the priorty list, but Powweb is always trying to improve in any area they can as long as it's a feasible and reasonable request.