Barre de progression dynamic javascript

Par iamlouky, il y a 8 ans


Bonjour,
J'aimerais lorsque le code javascript se charge jusqu'à 25%, ça soit dirigé automatiquement vers une autre page(par exemple href="verification/index.php").
Le problème est que je ne suis pas bon en javascript donc je ne sais pas par où il faut mettre le lien de la page où elle doit être dirigé .
voici mon code :

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <style type="text/css"> .bs-example{ margin: 20px; } </style> </head> <body> <div class="bs-example"> <!-- Progress bar HTML --> <div class="progress progress-striped active"> <div class="progress-bar"></div> </div> <!-- jQuery Script --> <script type="text/javascript"> var i = 0; function makeProgress(){ if(i < 25){ i = i + 1; $(".progress-bar").css("width", i + "%").text(i + " %"); } // Wait for sometime before running this script again setTimeout("makeProgress()", 500); } makeProgress(); </script> </div> </body> </html>

6 réponses

Pierrot01, il y a 8 ans
if(i < 25){ i = i + 1; $(".progress-bar").css("width", i + "%").text(i + " %"); } // ici !!!!
Pierrot01, il y a 8 ans

salut

else{ window.location = "verification/index.php"; }

@plus
Pierre

iamlouky, il y a 8 ans

Merci pour votre réponse rapide. Je rappelle que je suis un débutant. Je mets ca où dans le code svp ?

42 Hedgard, il y a 8 ans

Généralement un else se met après un if

iamlouky, il y a 8 ans

Je rappelle que je suis un débutant. Je mets ca où dans mon code svp ?

iamlouky, il y a 8 ans

Super ça marche très bien. Merci à