Javascript: Les fenêtres



1. Ouvrir une seconde fenêtre


L'événement "onclick" est utilsé pour ouvrir une seconde 
fenêtre et la fermer soit à partir de la page courante, 
soit à parir de la seconde fenêtre.

example:
On ouvre la fenêtre "picture1.html" et on la ferme à 
partir de page courante:
<HTML>
<HEAD>
<TITLE>seconde fenêtre</TITLE>
</head>
<BODY>

<FORM><table><tr>
<td>
<INPUT TYPE="button" VALUE="Ouvrer une seconde fenêtre"
onClick="msgWindow=window.open('picture1.html','window2',
'resizable=yes,width=600,height=500')"; id = "wind1"; 
onmouseover= "this.style.background = '#FFE4E1'";
onmouseout= "this.style.background = '#AFEEEE'";>   
</td>
<td>
<INPUT TYPE="button" VALUE="Fermer cette fenêtre"
onClick="msgWindow.close()"; id = "wind2"; 
onmouseover= "this.style.background = '#FFEFD5'";
onmouseout= "this.style.background = '#E6E6FA'";>   
</td></tr></table>
</FORM>

</BODY>
</HTML>

Pour fermer la fenêtre "picture1.html" à partir d'elle même, on y insère un code soit avec une form, soit avec un link. Soit: <form> <input type=button value="Fermer cette fenêtre" onClick="javascript:window.close();"> </form> Soit: <a href="javascript:window.close();">Fermer cette fenêtre</a>

2. Les differents types de fenêtres


Exemples:

1. Juste l'alarme: <a href="picture2.html" onClick="window.alert('Bonjour .. '); 
return false;">Alarme</a></li>

2. Alarme et accès à la page: <a href="picture2.html" onClick="window.alert('Bonjour .. ')">Alert et accès</a>

3. prompt et acces à la page: <a href="picture2.html" onClick="status = window.prompt('Votre ID: ', ''); return
false;">Prompt et accès</a></li>

3. Acces à la page avec confirmation: <a href="picture2.html" onClick="return window.confirm('Confirm 
redirection to picture2.html ?');">Ouvrir une page</a> 

4. Ouvrir deux pages: <a href="picture2.html" onClick="window.open('picture2.html', 'SS'); return
false;">Deux pages</a>

5. Sans status et sans location: <a href="picture2.html" onClick="window.open('picture2.html', 'SS',
'status=no,location=no'); return false;">Sans status et sans location</a> 

6. Avec location (=Ouvrir une page): <a href="picture3.html" 
onClick="window.location='picture3.html'; return false">Avec location</a>

7. Avec location.replace: <a href="picture3.html" onMouseOver="window.status='go to picture3.html'; 
return true" onClick="window.location.replace('picture3.html'); return true">Avec location.replace </a>

8. Pour avancer dans les pages, on utilise la méthode history.forward(). Pour reculer, on utilise 
history.back(), comme suit:
<form><input type="button" value="Prochaine page" onclick="history.forward();"></form>
<form><input type="button" value="Dernière page" onclick="history.back();"></form>

1. Juste l'alarme: Alarme
2. Alarme et accès à la page: Alert et accès
3. prompt et acces à la page: Prompt et accès
3. Acces à la page avec confirmation: Ouvrir une page 
4. Ouvrir deux pages: Deux pages
5. Sans status et sans location: Sans status et sans location 
6. Avec location (= Ouvrir une page): Avec location
7. Avec location.replace: Avec location.replace 
8. Avancer et reculer: