Movatterモバイル変換


[0]ホーム

URL:


  1. Tecnologia Web para desenvolvedores
  2. APIs da Web
  3. Window

Esta página foi traduzida do inglês pela comunidade.Saiba mais e junte-se à comunidade MDN Web Docs.

View in EnglishAlways switch to English

Window

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨julho de 2015⁩.

* Some parts of this feature may have varying levels of support.

O objetowindow representa uma janela que contém um elemento DOM; a propriedadedocument aponta para odocumento DOM document carregado naquela janela. Uma janela para um dado documento pode ser obtido usando a propriedadedocument.defaultView.

Esta seção provê uma breve referência a todos os métodos, propriedades e eventos disponíveis através do objeto DOMwindow. O objetowindow implementa a interfaceWindow, o qual herda da interfaceAbstractView. Algumas funções globais, objeto de namespace, interfaces e construtores, apesar de não tipicamente associados ao objeto em questão, estão disponíveis e estão listados nas referênciasJavaScript Reference eDOM Reference.

Em um navegador com suporte a abas, como o Firefox, cada aba contém seu próprio objetowindow (e, se você estiver escrevendo uma extensão, a janela do navegador é uma janela distinta também - vejaWorking with windows in chrome code para mais informação). Isto é, o objetowindow não é compartilhado entre as abas na mesma janela. Alguns métodos, nomeadamentewindow.resizeTo ewindow.resizeBy aplicam-se à janela toda e não à aba em questão ao que o objetowindow pertence. Geralmente, qualquer coisa que não pode racionalmente pertencer a uma aba, pertence a uma janela..

Propriedades

Esta interface herda propriedades da interfaceEventTarget e implementa propriedades deWindowTimers,WindowBase64, eWindowEventHandlers.

Perceba que propriedades que são objetos (ex.: sobrecarregar o protótipo de elementos built-in) são listados em uma sessão separada abaixo.

Window.applicationCacheSomente leitura

Um objetoOfflineResourceList fornece acesso aos recursos offline para o window.

Window.closedNão padrãoSomente leitura

Esta propriedade indica quando a window atual está fechada ou não.

Window.ComponentsNão padrão

O ponto de entrada para muitas características XPCOM. Algumas propriedades, por exemplo, classes, estão apenas disponíveis para código suficientemente privilegiado. Código de Web não deve usar essa propriedade.

Window.consoleNão padrãoSomente leitura

Retorna uma referência para o objeto console fornecendo acesso ao console debugging do navegador.

Window.content and Window.contentNão padrãoSomente leitura

Retorna uma referência para o elemento de conteúdo na janela atual. A variante obsoleta com sublinhado não está disponível a partir do conteúdo da Web.

Window.controllersNão padrãoSomente leitura

Retorna os objetos de controlador XUL para a janela atual do crome.

Window.cryptoSomente leitura

Retorna o objeto de criptografia do navegador.

Window.defaultStatus

Obtém/define o texto da barra de status para determinada janela.

Window.devicePixelRatioNão padrãoSomente leitura

Returns the ratio between physical pixels and device independent pixels in the current display.

Window.dialogArgumentsSomente leitura

Gets the arguments passed to the window (if it's a dialog box) at the timewindow.showModalDialog() was called. This is annsIArray.

Window.directories

Synonym ofwindow.personalbar

Window.documentSomente leitura

Retorna a referência à propriedadedocument que a janela contém.

Window.frameElementSomente leitura

Returns the element in which the window is embedded, or null if the window is not embedded.

Window.framesSomente leitura

Returns an array of the subframes in the current window.

Window.fullScreen

This property indicates whether the window is displayed in full screen or not.

Window.globalStorageNão padrão

Unsupported since Gecko 13 (Firefox 13). UseWindow.localStorage instead.Was: Multiple storage objects that are used for storing data across multiple pages.

Window.historySomente leitura

Retorna a referência ao objetohistory.

Window.innerHeight

Gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar.

window.innerWidth

Gets the width of the content area of the browser window including, if rendered, the vertical scrollbar.

Window.lengthSomente leitura

Returns the number of frames in the window. See alsowindow.frames.

Window.locationSomente leitura

Gets/sets the location, or current URL, of the window object.

Window.locationbarSomente leitura

Returns the locationbar object, whose visibility can be toggled in the window.

WindowStorage.localStorageSomente leitura

Returns a reference to the local storage object used to store data that may only be accessed by the origin that created it.

Window.menubarSomente leitura

Returns the menubar object, whose visibility can be toggled in the window.

Window.messageManager

Returns themessage manager object for this window.

Window.mozAnimationStartTimeSomente leitura

The time in milliseconds since epoch at which the current animation cycle began.

Window.mozInnerScreenXSomente leituraNão padrão

Returns the horizontal (X) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. SeemozScreenPixelsPerCSSPixel innsIDOMWindowUtils for a conversion factor to adapt to screen pixels if needed.

Window.mozInnerScreenYSomente leituraNão padrão

Returns the vertical (Y) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. SeemozScreenPixelsPerCSSPixel for a conversion factor to adapt to screen pixels if needed.

Window.mozPaintCountNão padrãoSomente leitura

Returns the number of times the current document has been rendered to the screen in this window. This can be used to compute rendering performance.

Window.name

Pega/attribui o nome ao objetowindow.

Window.navigatorSomente leitura

Returns a reference to the navigator object.

Window.opener

Returns a reference to the window that opened this current window.

Window.outerHeightSomente leitura

Gets the height of the outside of the browser window.

Window.outerWidthSomente leitura

Gets the width of the outside of the browser window.

Window.pageXOffsetSomente leitura

An alias forwindow.scrollX.

Window.pageYOffsetSomente leitura

An alias forwindow.scrollY

WindowSession.sessionStorageSomente leitura

SpeechSynthesisGetter.speechSynthesisSomente leitura

Window.parentSomente leitura

Returns a reference to the parent of the current window or subframe.

Window.performanceSomente leitura

Provides a hosting area forperformance related attributes.

Window.personalbarSomente leitura

Returns the personalbar object, whose visibility can be toggled in the window.

Window.pkcs11

Formerly provided access to install and remove PKCS11 modules.

Window.returnValue

The return value to be returned to the function that calledwindow.showModalDialog() to display the window as a modal dialog.

Window.screenSomente leitura

Returns a reference to the screen object associated with the window.

Window.screenXSomente leitura

Returns the horizontal distance of the left border of the user's browser from the left side of the screen.

Window.screenYSomente leitura

Returns the vertical distance of the top border of the user's browser from the top side of the screen.

Window.scrollbarsSomente leitura

Returns the scrollbars object, whose visibility can be toggled in the window.

Window.scrollMaxXNão padrãoSomente leitura

The maximum offset that the window can be scrolled to horizontally, that is the document width minus the viewport width.

Window.scrollMaxYNão padrãoSomente leitura

The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height).

Window.scrollXSomente leitura

Returns the number of pixels that the document has already been scrolled horizontally.

Window.scrollYSomente leitura

Returns the number of pixels that the document has already been scrolled vertically.

Window.selfSomente leitura

Returns an object reference to the window object itself.

Window.sessionStorage

A storage object for storing data within a single page session.

Window.sidebarNão padrãoSomente leitura

Returns a reference to the window object of the sidebar.

Window.status

Gets/sets the text in the statusbar at the bottom of the browser.

Window.statusbarSomente leitura

Returns the statusbar object, whose visibility can be toggled in the window.

Window.toolbarSomente leitura

Returns the toolbar object, whose visibility can be toggled in the window.

Window.topSomente leitura

Returns a reference to the topmost window in the window hierarchy. This property is read only.

Window.windowSomente leitura

Returns a reference to the current window.

window[0],window[1], etc.

Returns a reference to thewindow object in the frames. SeeWindow.frames for more details.

Methods

This interface inherits methods from theEventTarget interface and implements methods fromWindowTimers,WindowBase64, andWindowEventHandlers.

EventTarget.addEventListener()

Register an event handler to a specific event type on the window.

Window.alert()

Displays an alert dialog.

WindowBase64.atob()

Decodes a string of data which has been encoded using base-64 encoding.

Window.back()Não padrão

Moves back one in the window history.

Window.blur()

Sets focus away from the window.

WindowBase64.btoa()

Creates a base-64 encoded ASCII string from a string of binary data.

Window.captureEvents()Deprecated

Registers the window to capture all events of the specified type.

Window.clearImmediate()

Cancels the repeated execution set usingsetImmediate.

WindowTimers.clearInterval()

Cancels the repeated execution set usingWindowTimers.setInterval().

WindowTimers.clearTimeout()

Cancels the repeated execution set usingWindowTimers.setTimeout().

Window.close()

Closes the current window.

Window.confirm()

Displays a dialog with a message that the user needs to respond to.

Window.disableExternalCapture()
Window.dispatchEvent()

Used to trigger an event.

Window.dump()

Writes a message to the console.

Window.enableExternalCapture()
Window.find()

Searches for a given string in a window.

Window.focus()

Sets focus on the current window.

Window.forward()Não padrão

Moves the window one document forward in the history.

Window.getAttention()

Flashes the application icon.

Window.getAttentionWithCycleCount()
Window.getComputedStyle()

Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element.

Window.getDefaulComputedStyle()

Gets default computed style for the specified element, ignoring author stylesheets.

Window.getSelection()

Returns the selection object representing the selected item(s).

Window.home()Não padrão

Returns the browser to the home page.

Window.matchMedia()

Returns aMediaQueryList object representing the specified media query string.

Window.maximize()
Window.minimize() (top-level XUL windows only)

Minimizes the window.

Window.moveBy()

Moves the current window by a specified amount.

Window.moveTo()

Moves the window to the specified coordinates.

Window.mozRequestAnimationFrame()

Tells the browser that an animation is in progress, requesting that the browser schedule a repaint of the window for the next animation frame. This will cause aMozBeforePaint event to fire before that repaint occurs.

Window.open()

Opens a new window.

Window.openDialog()

Opens a new dialog window.

Window.postMessage()

Provides a secure means for one window to send a string of data to another window, which need not be within the same domain as the first, in a secure manner.

Window.print()

Opens the Print Dialog to print the current document.

Window.prompt()

Returns the text entered by the user in a prompt dialog.

Window.releaseEvents()Deprecated

Releases the window from trapping events of a specific type.

Window.removeEventListener()

Removes an event listener from the window.

Window.resizeBy()

Resizes the current window by a certain amount.

Window.resizeTo()

Dynamically resizes window.

Window.restore()
Window.routeEvent()
Window.scroll()

Scrolls the window to a particular place in the document.

Window.scrollBy()

Scrolls the document in the window by the given amount.

Window.scrollByLines()

Scrolls the document by the given number of lines.

Window.scrollByPages()

Scrolls the current document by the specified number of pages.

Window.scrollTo()

Scrolls to a particular set of coordinates in the document.

Window.setCursor()

Changes the cursor for the current window

Window.setImmediate()

Executes a function after the browser has finished other heavy tasks

WindowTimers.setInterval()

Schedules the execution of a function each X milliseconds.

Window.setResizable
WindowTimers.setTimeout()

Sets a delay for executing a function.

Window.showModalDialog()

Displays a modal dialog.

Window.sizeToContent()

Sizes the window according to its content.

Window.stop()

This method stops window loading.

Window.updateCommands()

Updates the state of commands of the current chrome window (UI).

Event handlers

These are properties of the window object that can be set to establish event handlers for the various things that can happen in the window that might be of interest.

This interface inherits event handlers from theEventTarget interface and implements event handlers fromWindowTimers,WindowBase64, andWindowEventHandlers.

Nota:Starting in Gecko 9.0, you can now use the syntaxif ("onabort" in window) to determine whether or not a given event handler property exists. This is because event handler interfaces have been updated to be proper web IDL interfaces. SeeDOM event handlers for details.

GlobalEventHandlers.onabort

An event handler property for abort events on the window.

WindowEventHandlers.onbeforeunload

An event handler property for before-unload events on the window.

GlobalEventHandlers.onblur

An event handler property for blur events on the window.

GlobalEventHandlers.onchange

An event handler property for change events on the window.

GlobalEventHandlers.onclick

An event handler property for click events on the window.

GlobalEventHandlers.onclose

An event handler property for handling the window close event.

GlobalEventHandlers.oncontextmenu

An event handler property for right-click events on the window.

Window.ondevicelight

An event handler property for any ambient light levels changes

Window.ondevicemotion
Window.ondeviceorientation

An event handler property for any device orientation changes

Window.ondeviceproximity

An event handler property for device proximity event

GlobalEventHandlers.onerror

An event handler property forerror events raised on the window.

GlobalEventHandlers.onfocus

An event handler property forfocus events on the window.

WindowEventHandlers.onhashchange

An event handler property for hash change events on the window; called when the part of the URL after the hash mark ("#") changes.

GlobalEventHandlers.onkeydown

An event handler property forkeydown events on the window.

GlobalEventHandlers.onkeypress

An event handler property forkeypress events on the window.

GlobalEventHandlers.onkeyup

An event handler property forkeyup events on the window.

WindowEventHandlers.onlanguagechange

An event handler property forlanguagechange events on the window.

GlobalEventHandlers.onload

An event handler property for window loading.

GlobalEventHandlers.onmousedown

An event handler property for mousedown events on the window.

GlobalEventHandlers.onmousemove

An event handler property for mousemove events on the window.

GlobalEventHandlers.onmouseout

An event handler property for mouseout events on the window.

GlobalEventHandlers.onmouseover

An event handler property for mouseover events on the window.

GlobalEventHandlers.onmouseup

An event handler property for mouseup events on the window.

Window.onmozbeforepaint

An event handler property for theMozBeforePaint event, which is sent before repainting the window if the event has been requested by a call to theWindow.mozRequestAnimationFrame() method.

WindowEventHandlers.onpageshow

An event handler property for pageshow events on the window.

WindowEventHandlers.onpagehide

An event handler property for pagehide events on the window.

Window.onpaint

An event handler property for paint events on the window.

WindowEventHandlers.onpopstate

An event handler property for popstate events, which are fired when navigating to a session history entry representing a state object.

GlobalEventHandlers.onreset

An event handler property for reset events on the window.

GlobalEventHandlers.onresize

An event handler property for window resizing.

GlobalEventHandlers.onscroll

An event handler property for window scrolling.

GlobalEventHandlers.onselect

An event handler property for window selection.

GlobalEventHandlers.onsubmit

An event handler property for submits on window forms.

Window.onunload

An event handler property for unload events on the window.

Window.onuserproximity

An event handler property for user proximity events

Constructors

See also theDOM Interfaces.

Window.DOMParser
Window.GeckoActiveXObject
Image

Used for creating anHTMLImageElement.

Option

Used for creating anHTMLOptionElement

Window.QueryInterface
Window.XMLSerializer
Worker

Used for creating aWeb worker

Window.XPCNativeWrapper
Window.XPCSafeJSObjectWrapper

Interfaces

SeeDOM Reference

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp