Window.moveTo()

  • Revision slug: DOM/window.moveTo
  • Revision title: window.moveTo
  • Revision id: 373125
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

{{DomRef}}

Summary

Moves the window to the specified coordinates.

Syntax

window.moveTo(x, y) 

Parameters

  • x is the horizontal coordinate to be moved to.
  • y is the vertical coordinate to be moved to.

Example

function origin() {
  // moves to top left corner of screen
  window.moveTo(0, 0);
}

Notes

This function moves the window absolutely while {{domxref("window.moveBy")}} moves the window relative to its current location.

Since Firefox 7, it's no longer possible for a web site to move a window in a browser, according to the following rules:

  1. You can't move a window or tab that wasn’t created by {{domxref("window.open")}}.
  2. You can't move a window or tab when it’s in a window with more than one tab.

Specification

{{dom0}}

Revision Source

<div>
  {{DomRef}}</div>
<h2 id="Summary">Summary</h2>
<p>Moves the window to the specified coordinates.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox">
window.moveTo(<var>x</var>, <var>y</var>) 
</pre>
<h3 id="Parameters">Parameters</h3>
<ul>
  <li><code>x</code> is the horizontal coordinate to be moved to.</li>
  <li><code>y</code> is the vertical coordinate to be moved to.</li>
</ul>
<h2 id="Example" name="Example">Example</h2>
<pre class="brush:js">
function origin() {
  // moves to top left corner of screen
  window.moveTo(0, 0);
}</pre>
<h2 id="Notes">Notes</h2>
<p>This function moves the window absolutely while {{domxref("window.moveBy")}} moves the window relative to its current location.</p>
<p>Since Firefox 7, it's no longer possible for a web site to move a window in a browser, according to the <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=565541#c24">following rules</a>:</p>
<ol>
  <li>You can't move a window or tab that wasn’t created by {{domxref("window.open")}}.</li>
  <li>You can't move a window or tab when it’s in a window with more than one tab.</li>
</ol>
<h2 id="Specification">Specification</h2>
<p>{{dom0}}</p>
Revert to this revision