Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2003
    Location
    ontario, canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question problem inserting 2 java scripts, tutorials havnt helped me.. plz help

    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 "
    +"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
    Stu
    Take a look at my site..

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #3
    New Coder
    Join Date
    Jun 2003
    Location
    ontario, canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...
    Stu
    Take a look at my site..

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    New Coder
    Join Date
    Jun 2003
    Location
    ontario, canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    never mind.. your first post helped me ... i forgot to change the variable names... lol
    thanks a lot though
    Stu
    Take a look at my site..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •