Window.moveTo()

  • Revision slug: DOM/window.moveTo
  • Revision title: window.moveTo
  • Revision id: 59459
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment bug 565541; 68 words added, 2 words removed

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 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 window.open.
  2. You can't move a window or tab when it’s in a window with more than one tab.

Specification

DOM Level 0. Not part of specification.

{{ languages( { "ja": "ja/DOM/window.moveTo" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<h3 id="Summary">Summary</h3>
<p>Moves the window to the specified coordinates.</p>
<h3 id="Syntax">Syntax</h3>
<pre class="eval">window.moveTo(<em>x</em>, <em>y</em>) 
</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>
<h3 id="Example" name="Example">Example</h3>
<pre> function origin() {
    // moves to top left corner of screen
    window.moveTo(0, 0)
 }
</pre>
<h3 id="Notes">Notes</h3>
<p>This function moves the window absolutely while <a href="/en/DOM/window.moveBy" title="en/DOM/window.moveBy">window.moveBy</a> 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 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>
<h3 id="Specification">Specification</h3>
<p>DOM Level 0. Not part of specification.</p>
<p>{{ languages( { "ja": "ja/DOM/window.moveTo" } ) }}</p>
Revert to this revision