Movatterモバイル変換


[0]ホーム

URL:


  1. Mozilla
  2. Add-ons
  3. Browser extensions
  4. JavaScript APIs
  5. windows
  6. windows.update()

windows.update()

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

This is an asynchronous function that returns aPromise.

Syntax

js
let updating = browser.windows.update(  windowId,              // integer  updateInfo             // object)

Parameters

windowId

integer. ID of the window to update.

updateInfo

object. Object containing the properties to update.

drawAttentionOptional

boolean. Iftrue, 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 tofalse to cancel a previousdrawAttention request.

focusedOptional

boolean. Iftrue, brings the window to the front. If false, brings the next window in the z-order to the front.

heightOptional

integer. The height to resize the window to in pixels. This value is ignored for panels.

leftOptional

integer. The offset from the left edge of the screen to move the window to in pixels. This value is ignored for panels.

stateOptional

windows.WindowState. The new state of the window. Theminimized,maximized andfullscreen states cannot be combined withleft,top,width orheight.

titlePrefaceOptional

string. Use this to add a string to the beginning of the browser window's title. Depending on the underlying operating system, this might not work on browser windows that don't have a title (such as about:blank in Firefox).

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.

Return value

APromise that will be fulfilled with awindows.Window object containing the details of the updated window. If any error occurs, the promise will be rejected with an error message.

Examples

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

js
function onUpdated(windowInfo) {  console.log(`Updated window: ${windowInfo.id}`);}function onError(error) {  console.log(`Error: ${error}`);}browser.browserAction.onClicked.addListener((tab) => {  let updating = browser.windows.update(tab.windowId, {    left: 0,    top: 0,  });  updating.then(onUpdated, onError);});

Example extensions

Browser compatibility

Note:This API is based on Chromium'schrome.windows API. This documentation is derived fromwindows.json in the Chromium code.

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp