Redirection après un compte à rebour

Fermé
BrietGameYT Messages postés 2 Date d'inscription jeudi 28 mars 2019 Statut Membre Dernière intervention 31 mars 2019 - Modifié le 29 mars 2019 à 09:14
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 - 2 avril 2019 à 07:04
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 :)
A voir également:

1 réponse

jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650
29 mars 2019 à 09:21
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
BrietGameYT Messages postés 2 Date d'inscription jeudi 28 mars 2019 Statut Membre Dernière intervention 31 mars 2019
31 mars 2019 à 19:30
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
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650 > BrietGameYT Messages postés 2 Date d'inscription jeudi 28 mars 2019 Statut Membre Dernière intervention 31 mars 2019
2 avril 2019 à 07:04
Et l'event finish... tu penses qu'il sert à quoi ?
0
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