The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Javascript on homepage question. ( Solved )

2 posters

Go down

Javascript on homepage question. ( Solved ) Empty Javascript on homepage question. ( Solved )

Post by Kingdom Life 14/7/2008, 17:08

Hello Forumotion,

I recently found a code on a Javascripting website and would like to know if I can put it on my homepage. Here is the code:
Code:


//Pre-load your image below!
grphcs=new Array(6)
Image0=new Image();
Image0.src=grphcs[0]="http://i221.photobucket.com/albums/dd263/hellopayton/z1.png";
Image1=new Image();
Image1.src=grphcs[1]="http://i221.photobucket.com/albums/dd263/hellopayton/z1.png"
Image2=new Image();
Image2.src=grphcs[2]="http://i221.photobucket.com/albums/dd263/hellopayton/z1.png"
Image3=new Image();
Image3.src=grphcs[3]="http://i221.photobucket.com/albums/dd263/hellopayton/z1.png"
Image4=new Image();
Image4.src=grphcs[4]="http://i221.photobucket.com/albums/dd263/hellopayton/z1.png"
Image5=new Image();
Image5.src=grphcs[5]="http://i221.photobucket.com/albums/dd263/hellopayton/z1.png"

Amount=8; //Smoothness depends on image file size, the smaller the size the more you can use!
Ypos=new Array();
Xpos=new Array();
Speed=new Array();
Step=new Array();
Cstep=new Array();
ns=(document.layers)?1:0;
ns6=(document.getElementById&&!document.all)?1:0;

if (ns){
for (i = 0; i < Amount; i++){
var P=Math.floor(Math.random()*grphcs.length);
rndPic=grphcs[P];
document.write("[img]+rndPic+[/img]");
}
}
else{
document.write('');
for (i = 0; i < Amount; i++){
var P=Math.floor(Math.random()*grphcs.length);
rndPic=grphcs[P];
document.write('[img]'+rndPic+'[/img]');
}
document.write('

');
}
WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight;
WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth;
for (i=0; i < Amount; i++){                                                               
 Ypos[i] = Math.round(Math.random()*WinHeight);
 Xpos[i] = Math.round(Math.random()*WinWidth);
 Speed[i]= Math.random()*5+3;
 Cstep[i]=0;
 Step[i]=Math.random()*0.1+0.05;
}
function fall(){
var WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight;
var WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth;
var hscrll=(ns||ns6)?window.pageYOffset:document.body.scrollTop;
var wscrll=(ns||ns6)?window.pageXOffset:document.body.scrollLeft;
for (i=0; i < Amount; i++){
sy = Speed[i]*Math.sin(90*Math.PI/180);
sx = Speed[i]*Math.cos(Cstep[i]);
Ypos[i]+=sy;
Xpos[i]+=sx;
if (Ypos[i] > WinHeight){
Ypos[i]=-60;
Xpos[i]=Math.round(Math.random()*WinWidth);
Speed[i]=Math.random()*5+3;
}
if (ns){
document.layers['sn'+i].left=Xpos[i];
document.layers['sn'+i].top=Ypos[i]+hscrll;
}
else if (ns6){
document.getElementById("si"+i).style.left=Math.min(WinWidth,Xpos[i]);
document.getElementById("si"+i).style.top=Ypos[i]+hscrll;
}
else{
eval("document.all.si"+i).style.left=Xpos[i];
eval("document.all.si"+i).style.top=Ypos[i]+hscrll;
}
Cstep[i]+=Step[i];
}
setTimeout('fall()',20);
}

window.onload=fall
//-->
Here is the result of the code: http://hellopayton.sitebooth.com/penguins.html

I want this to make an image fall on my homepage like that. Is there any possible way?


Last edited by Nessa on 15/7/2008, 02:23; edited 1 time in total (Reason for editing : Edit: To Mark Topic as Solved)
avatar
Kingdom Life
Forumember

Posts : 69
Reputation : 0
Language : English

Back to top Go down

Javascript on homepage question. ( Solved ) Empty Re: Javascript on homepage question. ( Solved )

Post by Kingdom Life 14/7/2008, 22:59

Nevermind, I got this to work. Turns out the Flux Capacitor really did go into the Capacitation Mator 2,000. Who would've guessed?
avatar
Kingdom Life
Forumember

Posts : 69
Reputation : 0
Language : English

Back to top Go down

Javascript on homepage question. ( Solved ) Empty Re: Javascript on homepage question. ( Solved )

Post by Nessa 15/7/2008, 02:22

Kingdom Life wrote:Nevermind, I got this to work. Turns out the Flux Capacitor really did go into the Capacitation Mator 2,000. Who would've guessed?

Javascript on homepage question. ( Solved ) LOL


Since this problem appears to have been resolved, I will lock this thread and mark it as solved.

=> ( Members Problem Solved )

=> Locked

Nessa
Nessa
Nessa
Energetic

Female Posts : 6203
Reputation : 128
Language : English

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum