Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    My Javascript file can't see any images

    I am working on an assignment which needs to include a basic image slideshow. I'm fairly positive the code for it is fine. But for some reason it can't seem to see that there are any images in the page. Here are the links (it might be a bit slow, it wasn't designed for the internet.)

    http://www.magii.consoleradar.com/work/slideshow.html - The web page
    http://www.magii.consoleradar.com/work/slideshow.js - The Javascript file


    I have tried it on Firefox and Opera and got the same result on both of them. Anyone got any ideas?

    Edit: Sorry should have added I get this in the Firefox error window "Error: document.images.slideshow is undefined"
    Last edited by Dracs; 06-14-2008 at 07:30 AM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,147
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    Line 16
    Char 2
    document.getElementById(...) is null or not an object.

  • #3
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Maybe you wanted like this instead:
    Code:
    var slides = new Array();
    var whichimage=0;
    slides[0] = "images/slide1.jpg";
    slides[1] = "images/slide2.jpg";
    slides[2] = "images/slide3.jpg";
    slides[3] = "images/slide4.jpg";
    slides[4] = "images/slide5.jpg";
    slides[5] = "images/slide6.jpg";
    
    document.write("This document contains: ")
    document.write(slides.length + " images.") // You might mean this, if not just remove this part
    //document.write(document.images.length + " images.") // This is the original one
    
    function slideshow()
    {
    	var slideshowspeed = 2000;
    	document.getElementById("slideshow").src = slides[whichimage];
    	if(whichimage==slides.length)
    	whichimage=0;
    		setTimeout('slideshow()', slideshowspeed);
    		whichimage++;
    }
    window.onload=function(){slideshow(0);}
    slide3.jpg and slide4.jpg does'nt exist (yet).

    Hope it helps.
    Last edited by rangana; 06-14-2008 at 07:50 AM.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • Users who have thanked rangana for this post:

    Dracs (06-14-2008)

  • #4
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks rangana that seemed to work perfectly. I'm not too sure why mine wasn't working but thanks still.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •