PDA

View Full Version : Background scroller Java Script!


Vasudha
09-02-2002, 04:13 PM
THIS IS NOT A WA SCRIPT!

But can some one wiser then me work out why my animated lightening
on this page will not work!

Here are all the codes I am using on my site.




<center><img src="http://d21c.com/AnnesPlace/Hal/HalBan2.gif">
<img src="http://fours2.tripod.ca/llight.gif">
<img src="http://d21c.com/AnnesPlace/Hal/Tomb01.gif"><img src="http://members.linkopp.com/ent/juners/rlight.gif"></center>

<script>
B=document.all;
C=document.layers;
T1=new Array("http://fours2.tripod.ca/ghost0.gif",50,56,"http://fours2.tripod.ca/ghost0.gif",50,56,"http://fours2.tripod.ca/ghost0.gif",38,36,"http://fours2.tripod.ca/ghost0.gif",22,21,"http://fours2.tripod.ca/ghost0.gif",16,16,"http://fours2.tripod.ca/ghost0.gif",10,10)
nos=parseInt(T1.length/3)
rate=50
ie5fix1=0;
ie5fix2=0;
for (i=0;i<nos;i++){
createContainer("CUR"+i,i*10,i*10,i*3+1,i*3+2,"","<img src='"+T1[i*3]+"' width="+T1[(i*3+1)]+" height="+T1[(i*3+2)]+" border=0>")}
function createContainer(N,Xp,Yp,W,H,At,HT,Op,St){
with (document){
write((!B) ? "<layer id='"+N+"' left="+Xp+" top="+Yp+" width="+W+" height="+H : "<div id='"+N+"'"+" style='position:absolute;left:"+Xp+"; top:"+Yp+"; width:"+W+"; height:"+H+"; ");
if(St){
if (C)
write(" style='");
write(St+";' ")
}
else write((B)?"'":"");
write((At)? At+">" : ">");
write((HT) ? HT : "");
if (!Op)
closeContainer(N)
}
}
function closeContainer(){
document.write((B)?"</div>":"</layer>")
}
function getXpos(N){
return (B) ? parseInt(B[N].style.left) : C[N].left
}
function getYpos(N){
return (B) ? parseInt(B[N].style.top) : C[N].top
}

function moveContainer(N,DX,DY){
c=(B) ? B[N].style :C[N];c.left=DX;c.top=DY
}
function cycle(){
//if (IE5)
if (document.all&&window.print){
ie5fix1=document.body.scrollLeft;
ie5fix2=document.body.scrollTop;
}
for (i=0;i<(nos-1);i++){
moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1)))
}
}
function newPos(e){
moveContainer("CUR"+(nos-1),(B)?event.clientX+ie5fix1:e.pageX+2,(B)?event.clientY+ie5fix2:e.pageY+2
)
}
if(document.layers)
document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=newPos
setInterval("cycle()",rate)
</script>

<html>
<BODY>
<body background="http://members.linkopp.com/ent/juners/falling.gif">

<script language="JavaScript">
<!-- Begin
var backgroundOffset = 0;
var bgObject = eval('document.body');
function scrollBG(maxSize) {
backgroundOffset = backgroundOffset + 1;
if (backgroundOffset > maxSize) backgroundOffset = 0;
bgObject.style.backgroundPosition = "0 " + backgroundOffset;
}
var ScrollTimer = window.setInterval("scrollBG(307)", 64);
// End -->
</script>
<br>
<bgsound src=
"http://www.cavernsofblood.com/11ft/redoubtable.mid"autostart=true loop=4">
</html>

ConfusedOfLife
09-02-2002, 10:13 PM
I'm not wiser than you indeed, but I'm gonna work on this tomorrow morning, also, don't you think that's better if you told us what you really want? that lightning thing alone wasn't that clear for me! coz if you wana have such effect by changing the background color, then it doesn't need any scrolling.

Vasudha
09-03-2002, 06:22 AM
The scrolling background is working fine. I can't figure out
why the animated lightening doesnt work properly and why it takes
ages to load! Thanks for your help!

victoria_1018
09-03-2002, 07:59 AM
I did happen to view some of the program in the following website related to your problem. You may try browsing them and find out where it goes wrong.

http://www.jsmadeeasy.com/javascripts/Alert%20Scripts/List_test.asp

Regards

ConfusedOfLife
09-04-2002, 01:13 AM
It works fine in my computer, what browser are you using?