Window parentPropriété

Window 对象参考手册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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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>

Essayez-le vous-même »


Window 对象参考手册Objet Window Autres extensions