IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Besoin d'aide pour setTimeout


Sujet :

JavaScript

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 302
    Points : 141
    Points
    141
    Par défaut Besoin d'aide pour setTimeout
    Bonsoir, j'ai un petit soucis avec la fonction setTimeout. En effet je souhaiterai faire le meme principe que sur ce site. Exécuté une redirection apres l'enregistrement. Donc voila ce que je voulais faire mais apparement ça ne fonctionne pas :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <!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="fr" lang="fr">
    				<head>
    					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    					<title>...</title>
    					<link rel="stylesheet" type="text/css" title="" href="style/formulaire.css" />
    				</head>
    				<body>
    					<div id="corps">
    						Votre inscription a bien été effectué. Vous serez redirigé dans 5 secondes ou sinon cliquez sur ce lien.<br />
              <script language=\"javascript\">setTimeout(\"<a href='test.html'\"></a>, 5000)</script>";
    					</div>
    				  <div id="pied">
                <?php include("date.php"); ?>
              </div>
    				</body>
    				</html>
    .
    Ou dois-je faire comme cela :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <!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="fr" lang="fr">
    				<head>
    					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    					<title>...</title>
    					<link rel="stylesheet" type="text/css" title="" href="style/formulaire.css" />
    				</head>
    				<body>
    					<div id="corps">
    						Votre inscription a bien été effectué. Vous serez redirigé dans 5 secondes ou sinon cliquez sur ce lien.<br />
              <?php echo "<script language=\"javascript\">setTimeout(\"location.href='test.html'\", 3000)</script>"; ?>
    					</div>
    				  <div id="pied">
                <?php include("date.php"); ?>
              </div>
    				</body>
    				</html>
    Sachant qu'avec la methode php cela fonctionne mais ne peut ton pas le faire avec directement du html?

  2. #2
    Expert confirmé
    Avatar de le_chomeur
    Profil pro
    Développeur informatique
    Inscrit en
    Février 2006
    Messages
    3 653
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 3 653
    Points : 4 835
    Points
    4 835
    Par défaut
    Salut , remplace :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    setTimeout(\"<a href='test.html'\"></a>, 5000);
    par :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    setTimeout("self.location.href = 'test.html'"></a>, 5000);
    Bon courage

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 302
    Points : 141
    Points
    141
    Par défaut
    En mettant ce code, il ne fonctionne pas ma redirection ne s'effectue pas.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    				<!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="fr" lang="fr">
    				<head>
    					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    					<title>...</title>
    					<link rel="stylesheet" type="text/css" title="" href="style/formulaire.css" />
    				</head>
    				<body>
    					<div id="redirection">
    						<a href="#">Votre inscription a bien été effectué. Vous serez redirigé dans 5 secondes ou sinon cliquez sur ce lien.</a><br />
                <script language=\"javascript\">setTimeout("self.location.href = 'test.html'">, 5000);</script>
    					</div>
    				  <div id="pied">
                <?php include("date.php"); ?>
              </div>
    				</body>
    				</html>

  4. #4
    Expert confirmé
    Avatar de le_chomeur
    Profil pro
    Développeur informatique
    Inscrit en
    Février 2006
    Messages
    3 653
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 3 653
    Points : 4 835
    Points
    4 835
    Par défaut
    . . .
    il en faut pas échapper les caractères dans la déclaration du script :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <script language=\"javascript\">setTimeout("self.location.href = 'test.html'">, 5000);</script>
    en :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <script language="javascript">setTimeout("self.location.href = 'test.html'", 5000);</script>
    testé et aprouvé

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 302
    Points : 141
    Points
    141
    Par défaut
    Merci beaucoup.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. besoin d'aide pour une requête
    Par Damien69 dans le forum Langage SQL
    Réponses: 11
    Dernier message: 31/03/2004, 15h38
  2. besoin d'aide pour le composant DBComboBox
    Par jane2002 dans le forum Bases de données
    Réponses: 8
    Dernier message: 28/02/2004, 19h01
  3. [Kylix] besoin d'aide pour installer kylix3
    Par Sph@x dans le forum EDI
    Réponses: 3
    Dernier message: 11/02/2004, 13h53
  4. [TP]besoin d'aide pour commandes inconnues
    Par Upal dans le forum Turbo Pascal
    Réponses: 15
    Dernier message: 03/10/2002, 10h48
  5. Besoin d'aide pour l'I.A. d'un puissance 4
    Par Anonymous dans le forum C
    Réponses: 2
    Dernier message: 25/04/2002, 17h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo