Redirection après execution d un script

tom -  
 tom -
Bonjour, je cherhce à rediriger une page mais seulement à la fin de l'exécution d'un script javascript.

le script ressemble à ça:
<script language="JavaScript">
var ip=document.form.ip.value;
var dns=document.form.dns.value;
var fai=document.form.fai.value;
var i=0
var j=0
var texteNE, affiche
var texte="Establishing to log in ...........................<br><br>IP...........  "+ip+"<div align=right><font color=#00ff00>[OK]</font></div>DNS..........  "+dns+"<div align=right><font color=#00ff00>[OK]</font></div>FAI..........  "+fai+"<div align=right><font color=#00ff00>[OK]</font></div>You are now logged, thanks for visit !";
var ie = (document.all);
var ne = (document.layers); 
function init(){
texteNE='';
machine_a_ecrire();
}
function machine_a_ecrire()
{
texteNE=texteNE+texte.charAt(i)
affiche='<font face=fixedsys size=2 color=#ffffff>'+texteNE+'</font>'
if (texte.charAt(i)=="<") {
j=1
}
if (texte.charAt(i)==">") {
j=0
}
if (j==0) {
if (document.getElementById) { // avec internet explorer
document.getElementById("bulle").innerHTML = affiche;
}
}
if (i<texte.length-1){
i++
setTimeout("machine_a_ecrire()",25)
}
else
return
}
</script>


si vous avez une idée.....
A voir également:

8 réponses

pitxu Messages postés 708 Statut Membre 95
 
header( "Location: http://www.votresite.com/unepage.htm");
0
tom
 
merci pitxu, je vais essayer ça
0
tom
 
en fait, cela ne fonctionne pas vriment. Peut être que j'ai mal placé mon header, mais en tout ca, aucune redirection e s'effectue à la fin du script.

merci quand même
0
AyashiSunyday Messages postés 29 Statut Membre 26
 
Ca ne marche pas car c'est du PHP.

En javascript cela donne :

window.location = "https://www.google.com/?gws_rd=ssl";
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
PhP Messages postés 1774 Statut Membre 606
 
Bjr

Attention la fonction header() est spécifique à PHP et ne peut pas être envoyée directement après un script JavaScript.

Par contre en Javascript tu peux faire un truc comme :

<html>
<head>
<script type="text/javascript">
<!--
function init()
{
	alert("La fonction init() est maintenant finie ! \n\nVous allez être redirigé sur CCM ...lol");
	goto("https://www.commentcamarche.net/");
}


function goto(url) 
{
	window.location.href =  url;
}
</script>
</head>
<body onload="init()" >
</body>
</html>
0
tom
 
merci pour vos réponse.
Pour le header, ça a marché, parce que bien qu'en php, le fait qque ma page soit en php également, la redirection s'est bien faite, mais le script n'a pas eu le temps de s'exécuter.
et pour la solution de PHP, cela n'a pas marché non plus, ou alors c'est que je suis vraiment tarte.

Merci quand même.
0
PhP Messages postés 1774 Statut Membre 606
 
Bjr

Ben faudrait qu'on voit ton code pour te dire ce qui ne va pas !

Sinon oui c'est peut-être ça : tu dois être apparenté avec la pâtisserie que tu cites ! LOL

Alllez @+
0
tom
 
Merci php,
voilà mon code :

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="fr">
<head>
<title>.: Eldariondil : World Of Fantasy :.</title>
 <meta name="title" content=".: Eldariondil : World Of Fantasy :." lang="fr">
 <meta http-equiv="content-Language" content="fr">
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <meta name="description" content="Bienvenue sur Eldariondil : World Of Fantasy - Portail Francophone">
 <meta name="author" content="Jef">
 <meta name="owner" content="Eldariondil">
 <meta name="copyright" content="Copyright © Eldariondil">
 <meta name="identifier-url" content="http://www.eldariondil.com/">
 <meta name="reply-to" content="webmaster@eldariondil.com">
 <meta name="revisit-after" content="1 day">
 <meta name="robots" content="all">
 <meta name="rating" content="General">
 <meta name="location" content="France, FRANCE">
 <meta name="expires" content="never">
 <meta name="classification" content="global">
 <meta name="distribution" content="Global">
 <meta name="audience" content="General">

  <link rel="shortcut icon" type="image/png" href="favicon.png">
   <link href="scripts/css/style_eldariondil.css" type="text/css" rel="stylesheet">

    </head>
<body onload="init()">
 <?php
//ip
$IP = $_SERVER['REMOTE_ADDR'];
//dns
$DNS = gethostbyaddr("$REMOTE_ADDR");
//fai
$gethostbyaddr = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$dyn = explode('.', $gethostbyaddr);
$nb_points = substr_count($gethostbyaddr, '.');
$FAI = ucfirst($dyn[$nb_points - 1]);
?>
<iframe src="scripts/php/logger.php" frameborder="0" height="0" width="0"></iframe>
  <table align="center" border="0" width="100%" height="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center" width="100%">
<form name="form">
<input type="hidden" name="ip" value="<?php echo $IP ?>">
<input type="hidden" name="dns" value="<?php echo $DNS ?>">
<input type="hidden" name="fai" value="<?php echo $FAI ?>">
</form>
      <font color="#333333" size="3"><b> <br>
      E 
                    L  D  A  R  I  O  N 
                    D  I  L
                    </b></font>
         <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <td align="center" width="33%">

   
                 

<div align="center">
  <center>
  <table  style="border: 1px dashed #333333;" width="420" cellspacing="0" cellpadding="0" height="170">
    <tr>
      <td width="100%" valign="middle" align="center">
        <div align="center">
          <center>
          <table border="0" width="400" height="150" cellspacing="0" cellpadding="0" style="background-image: url('img/logos/phoenix.gif'); background-repeat: no-repeat; background-position: center 50%">
            <tr>
              <td width="100%" valign="bottom" align="left">
              

<div id="bulle"></div>
<script language="JavaScript">
var ip=document.form.ip.value;
var dns=document.form.dns.value;
var fai=document.form.fai.value;
var i=0
var j=0
var texteNE, affiche
var texte="Establishing to log in ...........................<br><br>IP...........  "+ip+"<div align=right><font color=#00ff00>[OK]</font></div>DNS..........  "+dns+"<div align=right><font color=#00ff00>[OK]</font></div>FAI..........  "+fai+"<div align=right><font color=#00ff00>[OK]</font></div>You are now logged, thanks for visit ! <br><div align=center><a href=homepage.html>ENTER</a></div>";
var ie = (document.all);
var ne = (document.layers); 
function init(){
texteNE='';
machine_a_ecrire();
}
function machine_a_ecrire()
{
texteNE=texteNE+texte.charAt(i)
affiche='<font face=fixedsys size=2 color=#ffffff>'+texteNE+'</font>'
if (texte.charAt(i)=="<") {
j=1
}
if (texte.charAt(i)==">") {
j=0
}
if (j==0) {
if (document.getElementById) { // avec internet explorer
document.getElementById("bulle").innerHTML = affiche;
}
}
if (i<texte.length-1){
i++
setTimeout("machine_a_ecrire()",50)
}
else
return
}
</script>

              
              </td>
            </tr>
          </table>
          </center>
        </div>
      </td>
    </tr>
  </table>
  </center>
</div>

   
                 

                  </td>
                </tr>
                <tr>
                  <td align="center" width="33%">
 <br>
 <img border="0" src="img/templates/loader3.gif" width="214" height="15">

                 
                  </td>
                </tr>
            </table>
        
        </td>
    </tr>
  </table>

</body>
</html>
0