Window moveTo()Método
Objeto Window
Definición y uso
El método moveTo() mueve la esquina superior izquierda de la ventana a una coordenada especificada.
Sintaxis
window.moveTo(x,y)
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten el método moveTo()
Nota:Especifica moveTo(0,0) para mover la ventana a la esquina superior izquierda del navegador en Opera.
Ejemplo
Ejemplo
Mover la nueva ventana a la esquina superior izquierda de la pantalla:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<script>
function openWin(){
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>Esta es mi ventana</p>");
}
function moveWin(){
myWindow.moveTo(0,0);
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="Abrir ventana" onclick="openWin()" />
<br><br>
<input type="button" value="Mover ventana" onclick="moveWin()" />
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<script>
function openWin(){
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>Esta es mi ventana</p>");
}
function moveWin(){
myWindow.moveTo(0,0);
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="Abrir ventana" onclick="openWin()" />
<br><br>
<input type="button" value="Mover ventana" onclick="moveWin()" />
</body>
</html>
Pruébalo »
Objeto Window Otras extensiones