Window namePropriété
Objet Window
Définition et utilisation
La propriété name définit ou renvoie une chaîne qui stocke le nom de la fenêtre.
Syntaxe
window.name
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge la propriété name.
Exemple
Exemple
Renvoie le nom de la nouvelle fenêtre :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
var myWindow;
function openWin(){
myWindow=window.open('','MsgWindow','width=200,height=100');
myWindow.document.write("<p>The window name is: " + myWindow.name + "</p>");
}
</script>
</head>
<body>
<input type="button" value="Ouvrir ma fenêtre" onclick="openWin()" />
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
var myWindow;
function openWin(){
myWindow=window.open('','MsgWindow','width=200,height=100');
myWindow.document.write("<p>The window name is: " + myWindow.name + "</p>");
}
</script>
</head>
<body>
<input type="button" value="Ouvrir ma fenêtre" onclick="openWin()" />
</body>
</html>
Essayez-le vous-même »
Objet Window Autres extensions