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 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need assistance with adding two scripts to a webpage

    I followed the standard procedure when I was coding two javascripts into one page, but for some reason it won't work. Basically, I took one Javascript load option....window.onload=new for one and then I'm running the same script on another portion of the webpage so it's....window.onload=new as well.

    Anyway, I combined them both into the <body> tag so now it reads....<body onload="new();new()"> and I deleted the two loading codes from each rightful script. And it still won't work...I need help...will someone please come to my assistance?

    Thank you.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    you can't have 2 functions with the same name. Rename them like:

    <body onload="new1();new2()">
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Does that mean that I have to go through the entire script code and change everything that reads "new" to "new1" in the first script and "new2" in the second script? Here, I'll post the code I'm working with so you have an idea...

    <body onload="new();new()">

    <script language="JavaScript1.1">

    //Picture Cube slideshow - By Tony Foster III
    //Modifications by JK
    //Visit JavaScript Kit (http://javascriptkit.com) for script

    var specifyimage=new Array() //Your images
    specifyimage[0]="logos/clogo.gif"
    specifyimage[1]="logos/smfunk.gif"

    var delay=3000 //3 seconds

    //Counter for array
    var count =1;

    var cubeimage=new Array()
    for (i=0;i<specifyimage.length;i++){
    cubeimage[i]=new Image()
    cubeimage[i].src=specifyimage[i]
    }

    function movecube(){
    if (window.createPopup)
    cube.filters[0].apply()
    document.images.cube.src=cubeimage[count].src;
    if (window.createPopup)
    cube.filters[0].play()
    count++;
    if (count==cubeimage.length)
    count=0;
    setTimeout("movecube()",delay)
    }

    Function("setTimeout('movecube()',delay)")
    </script>

    <img src="photo1.jpg" name="cube" border=0 style="filterrogidXImageTransform.Microsoft.Stretch(stretchStyle='PUSH')">

    ---END OF SCRIPT 1---

    <script language="JavaScript1.1">

    //Picture Cube slideshow - By Tony Foster III
    //Modifications by JK
    //Visit JavaScript Kit (http://javascriptkit.com) for script

    var specifyimage=new Array() //Your images
    specifyimage[0]="logos/clogo.gif"
    specifyimage[1]="logos/smfunk.gif"

    var delay=3000 //3 seconds

    //Counter for array
    var count =1;

    var cubeimage=new Array()
    for (i=0;i<specifyimage.length;i++){
    cubeimage[i]=new Image()
    cubeimage[i].src=specifyimage[i]
    }

    function movecube(){
    if (window.createPopup)
    cube.filters[0].apply()
    document.images.cube.src=cubeimage[count].src;
    if (window.createPopup)
    cube.filters[0].play()
    count++;
    if (count==cubeimage.length)
    count=0;
    setTimeout("movecube()",delay)
    }

    Function("setTimeout('movecube()',delay)")
    </script>

    <img src="photo1.jpg" name="cube" border=0 style="filterrogidXImageTransform.Microsoft.Stretch(stretchStyle='PUSH')">

    Thanks.

  • #4
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oops...sorry about the smilies in the code...I don't think it matters though.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    why did you include the script twice?? And i can't find function named new()? I assume that the author includes direction on how to use the script.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay...here's the deal...I have a site setup, TheSportsMansion and I have two alternate logos that I want to use this effect on. I want the exact same effect on both logos.

    I posted the modified version of the code. Here is the original version of the code:

    <script language="JavaScript1.1">

    //Picture Cube slideshow - By Tony Foster III
    //Modifications by JK
    //Visit JavaScript Kit (http://javascriptkit.com) for script

    var specifyimage=new Array() //Your images
    specifyimage[0]="logos/clogo.gif"
    specifyimage[1]="logos/smfunk.gif"

    var delay=3000 //3 seconds

    //Counter for array
    var count =1;

    var cubeimage=new Array()
    for (i=0;i<specifyimage.length;i++){
    cubeimage[i]=new Image()
    cubeimage[i].src=specifyimage[i]
    }

    function movecube(){
    if (window.createPopup)
    cube.filters[0].apply()
    document.images.cube.src=cubeimage[count].src;
    if (window.createPopup)
    cube.filters[0].play()
    count++;
    if (count==cubeimage.length)
    count=0;
    setTimeout("movecube()",delay)
    }

    window.onload=new Function("setTimeout('movecube()',delay)")
    </script>

    <img src="photo1.jpg" name="cube" border=0 style="filterrogidXImageTransform.Microsoft.Stretch(stretchStyle='PUSH')">

    <p align="center"><font face="arial" size="-2">This free script provided by</font><br>
    <font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
    Kit</a></font></p>

    //You can see that there is a window.onload=new here in the orignal javascript. I tried to modify that part in each script (one for each logo) and place the onload function in the <body> tag.

    Take a look at my webpage and then go to the MVP Baseball section. This should show you what I'm looking for.

    Thanks a ton.

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    this is where you specify your images...

    var specifyimage=new Array() //Your images
    specifyimage[0]="logos/clogo.gif"
    specifyimage[1]="logos/smfunk.gif"

    just add more images as desired. you don't have to include the script twice. just edit the specifyimage array
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry to butt in here, but one note: new is a seriously reserved word in JavaScript.

    http://www.js-examples.com/javascrip.../keywords.php3

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    there is really no function new on onload as packman thought.

    window.onload=new Function("setTimeout('movecube()',delay)")

    he converted the above statement to:

    <body onload="new()">

    which is obviously wrong.
    I only realized just now what he did
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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