Window parentPropriété
Objet Window
Définition et utilisation
La propriété parent renvoie la fenêtre parente de la fenêtre actuelle.
Syntaxe
window.parent
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge la propriété parent.
Exemple
Exemple
Lors de l'ouverture d'une nouvelle fenêtre, afficher une alerte dans la fenêtre parente :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutoriel d'exemple (example.com)</title>
</head>
<head>
<script>
function openWin(){
window.open('','','width=200,height=100');
alert(window.parent.location);
}
</script>
</head>
<body>
<input type="button" value="Ouvrir la fenêtre" onclick="openWin()">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutoriel d'exemple (example.com)</title>
</head>
<head>
<script>
function openWin(){
window.open('','','width=200,height=100');
alert(window.parent.location);
}
</script>
</head>
<body>
<input type="button" value="Ouvrir la fenêtre" onclick="openWin()">
</body>
</html>
Essayez-le vous-même »
Objet Window Autres extensions