Jump to content

Eternu

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Eternu

  1. On 6/17/2016 at 7:19 PM, davej said:

    Well, this gets confusing because I don't know what you are using for html. In the slideshow here...

     

    http://www.w3schools.com/howto/howto_js_slideshow.asp

     

    With the html from the link above -- the following code works both manually and automatic...

    
    'use strict';
    var slideIndex = 1;
    
    function plusSlides(n) {
      showSlides(slideIndex += n);
    }
    
    function currentSlide(n) {
      showSlides(slideIndex = n);
    }
    
    function showSlides(n) {
      //alert('showslides('+ n +')\nslideIndex='+slideIndex);
      var i;
      var slides = document.getElementsByClassName("mySlides");
      var dots = document.getElementsByClassName("dot");
      if (n==undefined){n = ++slideIndex}
      if (n > slides.length) {slideIndex = 1}
      if (n < 1) {slideIndex = slides.length}
      for (i = 0; i < slides.length; i++) {
          slides[i].style.display = "none";
      }
      for (i = 0; i < dots.length; i++) {
          dots[i].className = dots[i].className.replace(" active", "");
      }
      slides[slideIndex-1].style.display = "block";
      dots[slideIndex-1].className += " active";
      
      setTimeout(showSlides, 5000); // Change image every 5 seconds
    }
    

    I have small problem with this code, coz it works and doesnt at the same time.  Problem is next, when i load page with slideshow images wont load, but if i click next button, previous or dot images appears and everything starts working as it should. I just dont know why it wont load image at the load of the page. I tried making clean page, with clean code like yours, and still same problem appear. Please help, it would mean a lot to me. Thanks in advance :)

×
×
  • Create New...