...

View Full Version : Need assistance with adding two scripts to a webpage



packman
06-16-2003, 08:29 AM
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? :confused:

Thank you.

glenngv
06-16-2003, 08:52 AM
you can't have 2 functions with the same name. Rename them like:

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

packman
06-16-2003, 08:58 AM
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="filter:progid:DXImageTransform.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="filter:progid:DXImageTransform.Microsoft.Stretch(stretchStyle='PUSH')">

Thanks.

packman
06-16-2003, 08:58 AM
oops...sorry about the smilies in the code...I don't think it matters though.

glenngv
06-16-2003, 09:57 AM
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.

packman
06-16-2003, 04:40 PM
Okay...here's the deal...I have a site setup, TheSportsMansion (http://thesportsmansion.com) 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="filter:progid:DXImageTransform.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.

glenngv
06-17-2003, 03:55 AM
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

cheesebagpipe
06-17-2003, 04:05 AM
Sorry to butt in here, but one note: new is a seriously reserved word in JavaScript.

http://www.js-examples.com/javascript/ref_js15/keywords.php3

glenngv
06-17-2003, 04:28 AM
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 :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum