Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

windows.update()

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

Updates the properties of a window. Use this to move, resize, and (un)focus a window, etc.

Note: If an error occurred (for example, because the window could not be found) then runtime.lastError will be set, and you should check for it in the callback.

Syntax

chrome.windows.update(
  windowId,              // integer
  updateInfo,            // object
  function(window) {...} // optional function
)

This API is also available as browser.windows.update() in a version that returns a promise.

Parameters

windowId
integer. ID of the window to update.
updateInfo
object. Object containing the properties to update.
leftOptional
integer. The offset from the left edge of the screen to move the window to in pixels. This value is ignored for panels.
topOptional
integer. The offset from the top edge of the screen to move the window to in pixels. This value is ignored for panels.
widthOptional
integer. The width to resize the window to in pixels. This value is ignored for panels.
heightOptional
integer. The height to resize the window to in pixels. This value is ignored for panels.
focusedOptional
boolean. If true, brings the window to the front. If false, brings the next window in the z-order to the front.
drawAttentionOptional
boolean. If true, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if the window already has focus. Set to false to cancel a previous drawAttention request.
stateOptional
windows.WindowState. The new state of the window. The minimized, maximized and fullscreen states cannot be combined with left, top, width or height.
callbackOptional
function. The function is passed the following arguments:
window
A windows.Window object representing the updated window.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes Yes 45.0 No 33

Examples

When the user clicks a browser action's icon, move the window to the top left corner:

chrome.browserAction.onClicked.addListener((tab) => {
  chrome.windows.update(tab.windowId, {
    left: 0,
    top: 0
  });
});

Acknowledgements

This API is based on Chromium's chrome.windows API. This documentation is derived from windows.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

ドキュメントのタグと貢献者

 このページの貢献者: Makyen, chrisdavidmills, wbamberg
 最終更新者: Makyen,