/    Sign up×
Community /Pin to ProfileBookmark

Javascript slideshow

Hello!
I have taked copy slideshow code (below) from javascriptkit.com, but ie need to get two slideshows in one page! i copy code twice and chage teh variable names etc. bat it doesn’t work… when i copy bouth slideshows in one page, only one of slideshows works… How can i fix it? tnx

Martin
[email][email protected][/email]

<script type=”text/javascript”>

// Flexible Image Slideshow- By JavaScriptKit.com ([url]http://www.javascriptkit.com[/url])
// For this and over 400+ free scripts, visit JavaScript Kit- [url]http://www.javascriptkit.com/[/url]
// This notice must stay intact for use

var ultimateshow=new Array()

//ultimateshow[x]=[“path to image”, “OPTIONAL link for image”, “OPTIONAL link target”]

ultimateshow[0]=[‘images/kamini/Untitled-1.jpg’, ”, ”]
ultimateshow[1]=[‘images/kamini/Untitled-2.jpg’, ”, ”]
ultimateshow[2]=[‘images/kamini/Untitled-3.jpg’, ”, ”]
ultimateshow[3]=[‘images/kamini/Untitled-4.jpg’, ”, ”]
ultimateshow[4]=[‘images/kamini/Untitled-5.jpg’, ”, ”]
ultimateshow[5]=[‘images/kamini/Untitled-6.jpg’, ”, ”]

//configure the below 3 variables to set the dimension/background color of the slideshow

var slidewidth=”100px” //set to width of LARGEST image in your slideshow
var slideheight=”125px” //set to height of LARGEST iamge in your slideshow
var slidecycles=”3″ //number of cycles before slideshow stops (ie: “2” or “continous”)
var randomorder=”yes” //randomize the order in which images are displayed? “yes” or “no”
var preloadimages=”yes” //preload images? “yes” or “no”
var slidebgcolor=’white’

//configure the below variable to determine the delay between image rotations (in miliseconds)
var slidedelay=3000

////Do not edit pass this line////////////////

var ie=document.all
var dom=document.getElementById
var curcycle=0

if (preloadimages==”yes”){
for (i=0;i<ultimateshow.length;i++){
var cacheimage=new Image()
cacheimage.src=ultimateshow[i][0]
}
}

var currentslide=0

function randomize(targetarray){
ultimateshowCopy=new Array()
var the_one
var z=0
while (z<targetarray.length){
the_one=Math.floor(Math.random()*targetarray.length)
if (targetarray[the_one]!=”_selected!”){
ultimateshowCopy[z]=targetarray[the_one]
targetarray[the_one]=”_
selected!”
z++
}
}
}

if (randomorder==”yes”)
randomize(ultimateshow)
else
ultimateshowCopy=ultimateshow

function rotateimages(){
curcycle=(currentslide==0)? curcycle+1 : curcycle
ultcontainer='<center>’
if (ultimateshowCopy[currentslide][1]!=””)
ultcontainer+='<a href=”‘+ultimateshowCopy[currentslide][1]+'” target=”‘+ultimateshowCopy[currentslide][2]+'”>’
ultcontainer+='<img src=”‘+ultimateshowCopy[currentslide][0]+'” border=”0″>’
if (ultimateshowCopy[currentslide][1]!=””)
ultcontainer+='</a>’
ultcontainer+='</center>’
if (ie||dom)
crossrotateobj.innerHTML=ultcontainer
if (currentslide==ultimateshow.length-1) currentslide=0
else currentslide++
if (curcycle==parseInt(slidecycles) && currentslide==0)
return
setTimeout(“rotateimages()”,slidedelay)
}

if (ie||dom)
document.write(‘<div id=”slidedom” style=”width:’+slidewidth+’;height:’+slideheight+’; background-color:’+slidebgcolor+'”></div>’)

function start_slider(){
crossrotateobj=dom? document.getElementById(“slidedom”) : document.all.slidedom
rotateimages()
}

if (ie||dom)
window.onload=start_slider

</script>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Logic_AliMay 24.2007 — Hello!

I have taked copy slideshow code (below) from javascriptkit.com, but ie need to get two slideshows in one page! i copy code twice and chage teh variable names etc. bat it doesn't work... when i copy bouth slideshows in one page, only one of slideshows works... How can i fix it? tnx
[/quote]
That's a difficult task with any script that uses global variables and functions. You may wish to try one that doesn't: [COLOR=SeaGreen][B]Link[/B][/COLOR]
×

Success!

Help @Blekss spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...