PDA

View Full Version : Request help add more than one of the same script to my site


norvin
01-05-2003, 09:33 PM
I am unfamiliar with Javascript so assistance from someone would be greatly appreciated.

I downloaded a script from the following url:
http://javascriptkit.com/script/script2/incrementslide.shtml.

The script provides a slideshow which will intelligently preload its images one at a time, while the preceding image is being shown. The script will actually "wait" until the next image is successfully preloaded before continuing, trying again if not.

I want to put four different slideshows on different areas of my page. Of course each show would have different images.

I read the tutorial located at http://www.javascriptkit.com/javatutors/multiplejava.shtml
regarding adding more than one script to a site however it did not seem to relate to this script

Thank you for your time and assistance.

Regards
Norman

The script is as follows:
<SCRIPT LANGUAGE="JavaScript">
<!--

/*
Script by FPMC at http://jsarchive.8m.com
Submitted to JavaScript Kit (http://javascriptkit.com)
For this and 400+ free scripts, visit http://javascriptkit.com
*/

//set image paths
src = ["image1.gif", "image2.gif", "image3.gif", "image4.gif"]


//set corresponding urls
url = ["http://freewarejava.com", "http://javascriptkit.com", "http://dynamicdrive.com", "http://www.geocities.com"]

//set duration for each image
duration = 4;

//Please do not edit below
ads=[]; ct=0;
function switchAd() {
var n=(ct+1)%src.length;
if (ads[n] && (ads[n].complete || ads[n].complete==null)) {
document["Ad_Image"].src = ads[ct=n].src;
}
ads[n=(ct+1)%src.length] = new Image;
ads[n].src = src[n];
setTimeout("switchAd()",duration*1000);
}
function doLink(){
location.href = url[ct];
} onload = function(){
if (document.images)
switchAd();
}
//-->
</SCRIPT>

<A HREF="javascript:doLink();" onMouseOver="status=url[ct];return true;"
onMouseOut="status=''">
<IMG NAME="Ad_Image" SRC="image1.gif" BORDER=0>
</A>

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

scroots
01-05-2003, 09:36 PM
try
<SCRIPT LANGUAGE="JavaScript">
<!--

/*
Script by FPMC at http://jsarchive.8m.com
Submitted to JavaScript Kit (http://javascriptkit.com)
For this and 400+ free scripts, visit http://javascriptkit.com
*/

//set image paths
src2 = ["image1.gif", "image2.gif", "image3.gif", "image4.gif"]


//set corresponding urls
url2 = ["http://freewarejava.com", "http://javascriptkit.com", "http://dynamicdrive.com", "http:// www.geocities.com"]

//set duration for each image
duration2 = 4;

//Please do not edit below
ads=[]; ct2=0;
function switchAd2() {
var n2=(ct+1)%src.length;
if (ads[n2] && (ads[n2].complete || ads[n2].complete==null)) {
document["Ad_Image2"].src = ads[ct2=n2].src;
}
ads[n2=(ct2+1)%src.length] = new Image;
ads[n2].src = src[n2];
setTimeout("switchAd2()",duration2*1000);
}
function doLink2(){
location.href = url[ct2];
} onload = function2(){
if (document.images)
switchAd2();
}
//-->
</SCRIPT>

<A HREF="java script:doLink2();" onMouseOver="status=url[ct2];return true;"
onMouseOut="status=''">
<IMG NAME="Ad_Image2" SRC="image1.gif" BORDER=0>
</A>

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

scroots
01-05-2003, 09:39 PM
all it is to do with is that the same variables are being used in the script so you need to give them all different names notice in my example it is n2 function 2 etc.

scroots