Redirection après un compte à rebour

BrietGameYT Messages postés 2 Statut Membre -  
jordane45 Messages postés 30427 Date d'inscription   Statut Modérateur Dernière intervention   -
Bonjour, j'ai grâce à ce code, un compte à rebour qui varie selon une date donnée. J'aimerais bien comprendre comme faire une redirection dès que le compte à rebour arrive à 0.

Voici le code JS :
$(window).load(function(){
     $('.preloader').fadeOut('slow');
});


/* =Main INIT Function
-------------------------------------------------------------- */
function initializeSite() {

 "use strict";

 //OUTLINE DIMENSION AND CENTER
 (function() {
     function centerInit(){

   var sphereContent = $('.sphere'),
    sphereHeight = sphereContent.height(),
    parentHeight = $(window).height(),
    topMargin = (parentHeight - sphereHeight) / 2;

   sphereContent.css({
    "margin-top" : topMargin+"px"
   });

   var heroContent = $('.hero'),
    heroHeight = heroContent.height(),
    heroTopMargin = (parentHeight - heroHeight) / 2;

   heroContent.css({
    "margin-top" : heroTopMargin+"px"
   });

     }

     $(document).ready(centerInit);
  $(window).resize(centerInit);
 })();

 // Init effect 
 $('#scene').parallax();

};
/* END ------------------------------------------------------- */

/* =Document Ready Trigger
-------------------------------------------------------------- */
$(window).load(function(){

 initializeSite();
 (function() {
  setTimeout(function(){window.scrollTo(0,0);},0);
  }
 })();

});
/* END ------------------------------------------------------- */


$('#countdown').countdown({
 date: "March 28, 2019 21:00:00",
 render: function(data) {
   var el = $(this.el);
   window.location.replace("https://monsite.fr/");
   el.empty()
     //.append("<div>" + this.leadingZeros(data.years, 4) + "<span>years</span></div>")
     .append("<div>" + this.leadingZeros(data.days, 2) + " <span>days</span></div>")
     .append("<div>" + this.leadingZeros(data.hours, 2) + " <span>hrs</span></div>")
     .append("<div>" + this.leadingZeros(data.min, 2) + " <span>min</span></div>")
     .append("<div>" + this.leadingZeros(data.sec, 2) + " <span>sec</span></div>");
 }
});


EDIT : Ajout des balises de code

Merci d'avance :)

1 réponse

  1. jordane45 Messages postés 30427 Date d'inscription   Statut Modérateur Dernière intervention   4 832
     
    Bonjour,

    Tu utilises, visiblement, un plugin "countdown"
    Il faut donc regarder sa documentation pour savoir comment detecter la fin du compte à rebours.

    Il y a certainement une methode "end"
    dans laquelle tu pourras déclencher ta redirection.

    0
    1. BrietGameYT Messages postés 2 Statut Membre
       
      Bonjour,

      Je regarde pourtant cette documentation officiel et je ne vois rien du tout qui va m'aider.

      http://hilios.github.io/jQuery.countdown/documentation.html
      0
      1. jordane45 Messages postés 30427 Date d'inscription   Statut Modérateur Dernière intervention   4 832 > BrietGameYT Messages postés 2 Statut Membre
         
        Et l'event finish... tu penses qu'il sert à quoi ?
        0
    2. narwouid
       
      Ce que je trouve bizarre c'est un setTimeOut au bout de 0 millisecondes... autant qu'il n'y en ait pas du tout alors.
      Et aussi window.location.replace() qui est une méthode de String et non de window.location , ça ne serais pas plutôt window.location.href = nouvelURL !
      0