|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
A little help with this Javascript slideshow needed
I have this fairly simple code i got from a Java site for a fading slideshow.
It works fine, but i want to loop 10 pictures. The code i copied and pasted was for 5 pics, it said to just keep adding the paths of the pics. This I did, but even though there are 10 pics there it will only scroll through 5, ignoring the other 5. What am i doing wrong? Code:
<script>
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully
// =======================================
// set the following variables
// =======================================
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 3000
// Duration of crossfade (seconds)
var crossFadeDuration = 3
// Specify the image files
// don't touch this
// to add more images, just continue
// the pattern, adding to the array below
var Pic = new Array()
Pic[0] = 'slideshow_images/1.jpg'
Pic[1] = 'slideshow_images/2.jpg'
Pic[2] = 'slideshow_images/3.jpg'
Pic[3] = 'slideshow_images/4.jpg'
Pic[4] = 'slideshow_images/5.jpg'
Pic[5] = 'slideshow_images/6.jpg'
Pic[6] = 'slideshow_images/7.jpg'
Pic[7] = 'slideshow_images/8.jpg'
Pic[8] = 'slideshow_images/9.jpg'
Pic[9] = 'slideshow_images/10.jpg'
// =======================================
// do not edit anything below this line
// =======================================
var t
var j = 0
var p = Pic.length
var preLoad = new Array()
for (i = 0; i < p; i++){
preLoad[i] = new Image()
preLoad[i].src = Pic[i]
}
function runSlideShow(){
if (document.all){
document.images.SlideShow.style.filter="blendTrans(duration=2)"
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
document.images.SlideShow.filters.blendTrans.Apply ()
}
document.images.SlideShow.src = preLoad[j].src
if (document.all){
document.images.SlideShow.filters.blendTrans.Play( )
}
j = j + 1
if (j > (p-1)) j=0
t = setTimeout('runSlideShow()', slideShowSpeed)
}
</script>
Thanks in advance |
|
#2
|
||||
|
||||
|
the code is fine, you probably see cached page.
clear your IE cache and try again. |
|
#3
|
|||
|
|||
|
Hi, thanks for looking. I've cleared my IE cache and still the same, only 5 in rotation.
I've also tried on another computer thats not been to the page before and its still 5 in rotation on that one too. It seems crazy, I don't understand javascript very well at all, but I can just about understand it and i can't see why it only rotates 5. I have viewed the source of the web page when its loaded and its identical to the script posted above. I have also tried forcing 'var p' to = 10, but still it only rotates through 5. its nuts ![]() |
|
#4
|
||||
|
||||
|
add the bolded line to the function in order to debug this:
Code:
function runSlideShow(){
alert(Pic.length + "\n" + preLoad.length);
if (document.all){
document.images.SlideShow.style.filter="blendTrans(duration=2)"
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
document.images.SlideShow.filters.blendTrans.Apply ()
}
document.images.SlideShow.src = preLoad[j].src
if (document.all){
document.images.SlideShow.filters.blendTrans.Play( )
}
j = j + 1
if (j > (p-1)) j=0
t = setTimeout('runSlideShow()', slideShowSpeed)
}
|
|
#5
|
|||
|
|||
|
I added the line and evertime i get a new slide i get the message 10 10.
I get the feeling this is how it should be, but still ony 5 rotate. (I'm not sure if it matters, but the 'head' part of the java is on one page, and the other part (where the slide show is) is on another web page that is incuded on this one. where i use <!--#Include file="right_column.asp"--> |
|
#6
|
||||
|
||||
|
ok, second step of the debug:
Code:
alert(j + "\n" + p); |
|
#7
|
|||
|
|||
|
now i get 0-5 1-5 2-5 3-5 4-5 then back to 0-5
|
|
#8
|
||||
|
||||
|
this works flawlessly at my computer.
please zip your whole page as-is and attach it here. |
|
#9
|
|||
|
|||
|
I hope this works
its crazy why this dosn't work. I've just copied and paset the code onto a blank page and it works fine on a new page. There is a javascript menu on the page, but its far beyond me to underatand it. i used Allwebmenu pro to construct it. If that helps |
|
#10
|
||||
|
||||
|
then something in the other .js code is messing up with one of the variables.
try to change your code to this: Code:
// ==============================================
// do not edit anything below this line (unless the code does not work and need to be fixed)
// ==============================================
var _fadeTimerSeed = 0;
var _fadeCurrentIndex = 0;
var _fadeImageCount = Pic.length;
var preLoad = new Array()
for (i = 0; i < _fadeImageCount; i++){
preLoad[i] = new Image()
preLoad[i].src = Pic[i]
}
function runSlideShow(){
if (document.all)
{
document.images.SlideShow.style.filter = "blendTrans(duration=2)";
document.images.SlideShow.style.filter = "blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply ();
}
document.images.SlideShow.src = preLoad[_fadeCurrentIndex].src;
if (document.all)
{
document.images.SlideShow.filters.blendTrans.Play( );
}
_fadeCurrentIndex = _fadeCurrentIndex + 1;
if (_fadeCurrentIndex > (_fadeImageCount - 1))
_fadeCurrentIndex = 0;
_fadeTimerSeed = setTimeout('runSlideShow()', slideShowSpeed);
}
Last edited by Shadow Wizard : May 1st, 2008 at 04:48 AM. |
|
#11
|
|||
|
|||
|
Thats fixed it.
Thank you soooooo much for your help ![]() |
|
#12
|
||||
|
||||
|
cheers, glad I could help.
feel free to email those who wrote the code and notify them of their problem - the code is poorly written. this way maybe they will change the code and use real variable names and thus make the code better and such problems as yours will be prevented. the greatest mistake of those writing "shared" code is the assumption their code is the only code that will ever exist in the page. well, they're wrong and your case prove this. ![]() you can send them link to this thread. |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > A little help with this Javascript slideshow needed |
| Thread Tools | Search this Thread |