...

View Full Version : problem inserting 2 java scripts, tutorials havnt helped me.. plz help



wasnt_me
06-03-2003, 12:05 AM
im trying to put 2 java scripts on my web site, and they are conflicting with each other. i have been through the tutorial on this site, but it hasnt really helped me. if u could please help me i would really appriciate it.. Both of the scripts work fine by themselves.. Here are the original scripts that i am trying to put on:


SCRIPT 1
(this script is a text scroller on the status bar..)



<!-- scroller in bottom of screen -->
<script language="Javascript">

<!--

var x = 0
var y = 0
var z = 140
var delay = 70
var text ="Welcome to my site:D "
+"Be sure to check out the forum, and sign the guestbook if u havn't allready... "
+"And TAG, you're it!! (leave a message on the tag board, lol)"

while (y ++ < z) {
text = " " + text
}

function scroller() {
window.status = text.substring(x++, text.length);
if (x == text.length) {
x = 0;
}
setTimeout("scroller()", delay);
}

scroller();
//-->


SCRIPT 2
(this script displays a cursor moving randomly around a screen.. )




<SCRIPT language="JavaScript1.2">

//specify path to cursor image
var cursorpath="cursor5.gif"

if (document.layers)
{document.write("<LAYER NAME='PoInTeRs' LEFT=10 TOP=10><img src='"+cursorpath+"' width=17 height=22></LAYER>")}
else if (document.all){document.write("<div id='pOiNtErS' style='position:absolute;top:10px;left:10px;width:17px;height:22px;z-index:50'><img src='"+cursorpath+"' width=17 height=22></div>")}

count=-1;
move=1;

function Curve(){
abc=new Array(0,1,1,1,2,3,4,0,6,-1,-1,-1,-2,-3,-4,0,-6)
for (i=0; i < abc.length; i++)
{var C=Math.round(Math.random()*[i])}
howbend=abc[C];
setTimeout('Curve()',1900);
return howbend;
}
ypos=10;
xpos=10;

degree = 60;
function MoveRandom(){
PathBend=degree+=howbend;//ok!
y = 4*Math.sin(PathBend*Math.PI/180);
x = 6*Math.cos(PathBend*Math.PI/180);
if (document.layers){
ypos+=y;
xpos+=x;
document.PoInTeRs.top=ypos+window.pageYOffset;
document.PoInTeRs.left=xpos+window.pageXOffset;
}
else if (document.all){
ypos+=y;
xpos+=x;
document.all.pOiNtErS.style.top=ypos+document.body.scrollTop;
document.all.pOiNtErS.style.left=xpos+document.body.scrollLeft;
}
T=setTimeout('MoveRandom()',50);
}
function edges(){
if (document.layers){
if (document.PoInTeRs.left >= window.innerWidth-40+window.pageXOffset)degree=Math.round(Math.random()*45+157.5);
if (document.PoInTeRs.top >= window.innerHeight-30+window.pageYOffset)degree=Math.round(Math.random()*45-112.5);
if (document.PoInTeRs.top <= 2+window.pageYOffset) degree = Math.round(Math.random()*45+67.5);//OK!
if (document.PoInTeRs.left <= 2+window.pageXOffset) degree = Math.round(Math.random()*45-22.5);//OK!
}
else if (document.all)
{
if (document.all.pOiNtErS.style.pixelLeft >= document.body.offsetWidth-45+document.body.scrollLeft)degree=Math.round(Math.random()*45+157.5);
if (document.all.pOiNtErS.style.pixelTop >= document.body.offsetHeight-35+document.body.scrollTop)degree=Math.round(Math.random()*45-112.5);
if (document.all.pOiNtErS.style.pixelTop <= 2+document.body.scrollTop) degree = Math.round(Math.random()*45+67.5);//OK!
if (document.all.pOiNtErS.style.pixelLeft <= 2+document.body.scrollLeft) degree = Math.round(Math.random()*45-22.5);//OK!
}
setTimeout('edges()',100);
}
function starteffect(){
Curve();
MoveRandom();// onUnload="opener.gO()"
edges();
}

if (document.all||document.layers)
window.onload=starteffect
</script>


I would appreciate any help that you could give me.. thanks:thumbsup:

whammy
06-03-2003, 12:21 AM
I'm not sure why the tutorial wouldn't help - you've still got the:

window.onload=starteffect

...in your script, so you didn't do what the tutorial said!

I'm assuming your other script uses onload in the body tag, so REMOVE the part above, and put it in the body tag with the other one like:

<body onload="function1(); function2()">

If you still get errors, make sure you rename any variables the scripts might share that are global in scope.

wasnt_me
06-03-2003, 12:33 AM
ya, i tried what the tutorial said, but i posted the original scripts... even when i followed the tutorial they still didnt work.. the cursor floating around would just over ride the scroller.. but with out the cursor in the <body onload='whatever'>, the scroller would work,
but not with both of them in htere together... so i dont kno whats going on...:(

whammy
06-03-2003, 12:35 AM
Ouch... well first of all, your body tag looks like this:

<body bgcolor="#000000" text="#00FF00" link="#238DF8" vlink="#238DF8"</FONT>

That surely will not work...

wasnt_me
06-03-2003, 12:52 AM
never mind.. your first post helped me:) ... i forgot to change the variable names... lol
thanks a lot though:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum