After encountering issues with my slideshow, I decided to declare a variable outside of an external JS file due to part of it being generated server-side.
<script type="text/javascript">
var images=new Array(<%= Master.slideshowArray %>);
</script>
I noticed that removing this code from the external JS file caused the slideshow to stop working. I suspect that I may have incorrectly declared it as a global variable or there could be another global declaration needed. Any suggestions?
var nextimage=0;
doSlideshow();
function doSlideshow()
{
if($('.backgroundImage').length!=0)
{
$('.backgroundImage').fadeOut(500,function(){slideshowFadeIn();$(this).remove();});
}
else
{
slideshowFadeIn();
}
}
function slideshowFadeIn()
{
if(nextimage>=images.length)
nextimage=0;
$('.homeLeadContent').prepend($('<img class="backgroundImage" src="'+images[nextimage++]+'" style="display:none;">').fadeIn(500,function() {
setTimeout(doSlideshow,1000);
}));
}