Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8934699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:50:50+00:00 2026-06-15T09:50:50+00:00

I am trying to make a slideshow from the book Javascript in 24 Hours

  • 0

I am trying to make a slideshow from the book Javascript in 24 Hours from 2008. I think I have copied the code identically, yet the pictures shuffle, but they do not slide in as the book says they should. Does anyone mind taking the time to look this over?
Thanks in advance!

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Slideshow</title>
<style>
img.slide {
position: absolute;
left:0;
top:0;
}

#slideshow {
    position:relative;
    overflow:hidden;
    width:400px;
    height:400px;
}
</style>

<script>
// Slideshow
// Global variables
var numslides=0;
var currentslide=0,oldslide=4;
var x = 0;
var slides = new Array();
function MakeSlideShow() {
imgs=document.getElementsByTagName("img");
for (i=0; i<imgs.length; i++) {
    if (imgs[i].className != "slide") continue;
    slides[numslides]=imgs[i];
    //Stack images with the first slide on top
    if (numslides==0) {
        imgs[i].style.zIndex=10;
    }
    else {
        imgs[i].style.zIndex=0;
    }
    imgs[i].onclick=NextSlide;
    numslides++;
} // end for loop
}// end MakeSlideShow

function NextSlide() {
//Set the current slide to be under the new top slide
slides[currentslide].style.zIndex=9;
// Move older slide to the bottom of the stack
slides[oldslide].style.zIndex=0;
oldslide = currentslide;
currentslide++;
if (currentslide >= numslides) currentslide = 0;
// Start at the right edge
slides[currentslide].style.left=400;
x=400;
//Move the new slide to the top
slides[currentslide].style.zIndex=10;
AnimateSlide();
}

function AnimateSlide() {
// Lower moves slower, higher moves faster
x = x - 25;
slides[currentslide].style.left=x;
//Previous image moves off the left edge
slides[oldslide].style.left=x-400;
//Repeat until until the slide is at the zero position
if (x > 0) window.setTimeout("AnimateSlide();",10);
}
</script>
</head>

<body onload="MakeSlideShow();">
            <div id = "slideshow">
                <img class = "slide" src = "pic1.jpg" width = "400px" height = "400px" >
                <img class = "slide" src = "pic2.jpg" width = "400px" height = "400px" >
                <img class = "slide" src = "pic3.jpg" width = "400px" height = "400px" >
                <img class = "slide" src = "pic4.jpg" width = "400px" height = "400px" >
                <img class = "slide" src = "pic5.jpg" width = "400px" height = "400px" >
            </div>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:50:50+00:00Added an answer on June 15, 2026 at 9:50 am

    Hi Your script is very fine …

    The problem is in two lines of this function

        function AnimateSlide() {
        ...
        ...
        slides[currentslide].style.left=x;
        slides[oldslide].style.left=x-400;
        ...
        }
    

    Modification is that left value should have “px”. So Modified Lines are

    slides[currentslide].style.left=x +"px";
    slides[oldslide].style.left=x-400 +"px";
    

    Now it is sliding. jsfiddle Demo path is http://jsfiddle.net/naveenksh/Jvkcc/5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a slideshow of images and all I have is a
I'm trying to make a full screen slideshow kind of effect jsFiddle code here
I am trying to make a slideshow-like application in Java using NetBeans. I have
I'm trying make this code which is from a Dictionary of Arrays (CODE) from
I'm trying to make a slideshow using Jquery, the pictures are cycled by a
I am trying to make a slideshow-like thing with JavaScript for a website and
I'm trying to make a javascript slideshow that has a forward and back button.
Trying to make the infamous checkall checkbox for dynamically created rows from a MySQL
Trying to make a cross protocol, same domain request from https to http. I
im trying make one replace in string from a array but this dont work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.