Window moveBy()Méthode
Objet Window
Définition et utilisation
La méthode moveBy() déplace la fenêtre du nombre de pixels spécifié par rapport à ses coordonnées actuelles.
Syntaxe
window.moveBy(x,y)
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge la méthode moveBy()
Exemple
Exemple
Déplacer la fenêtre de 250 pixels par rapport à sa position actuelle :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutoriel d'exemple (example.com)</title>
<script>
function openWin(){
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>Ceci est ma fenêtre</p>");
}
function moveWin(){
myWindow.moveBy(250,250);
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="Ouvrir ma fenêtre" onclick="openWin()" />
<br><br>
<input type="button" value="Déplacer ma fenêtre" onclick="moveWin()" />
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutoriel d'exemple (example.com)</title>
<script>
function openWin(){
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>Ceci est ma fenêtre</p>");
}
function moveWin(){
myWindow.moveBy(250,250);
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="Ouvrir ma fenêtre" onclick="openWin()" />
<br><br>
<input type="button" value="Déplacer ma fenêtre" onclick="moveWin()" />
</body>
</html>
Essayez-le vous-même »
Objet Window Autres extensions