window
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since julio de 2015.
* Some parts of this feature may have varying levels of support.
El objeto window representa la ventana que contiene un documento DOM; la propiedad document apunta al DOM document cargado en esa ventana. El objeto window al que pertenece un documento puede ser obtenido usando la propiedad document.defaultView.
Esta sección proporciona una pequeña referencia a todos los métodos, propiedades y eventos disponibles a través del objeto DOM window. El objeto window implementa la interfaz Window , que a su vez hereda de la interfaz AbstractView. Algunas funciones como globales adicionales, espacios de nombres, interfaces, y constructores no típicamente asociados con el objeto window pero disponibles en éste, están listados en las Referencia de JavaScript y en el Referencia DOM de Gecko.
En un navegador con pestañas, como Firefox, cada pestaña contine su propio window object (y si está escribiendo una extensión, la ventana del navegador es una ventana separada también - para más información vea Trabajar con ventanas desde el código chrome). Esto significa que el objeto window no se comparte entre diferentes pestañas de la misma ventana del navegador. Algunos métodos, como window.resizeTo y window.resizeBy se aplican sobre toda la ventana del navegador y no sobre una pestaña específica a la que pertenece el objeto window. Generalmente, cualquier cosa que razonablemente no pueda pertenecer a una pestaña, pertenece a la ventana.
Constructores
Ver también DOM Interfaces.
Window.DOMParser-
DOMParserpuede traducir una fuente XML o HTML almacenada en una cadena en un Documento DOM.DOMParserse especifica en DOM Parsing and Serialization. Image-
Se usa para crear un
HTMLImageElement. Option-
Se usa para crear un
HTMLOptionElement
StaticRangeRead only-
Retorna un constructor
StaticRange()que crea un objetoStaticRange.
Worker-
Se usa para crear un Web worker.
Window.XMLSerializer-
Convierte un árbol DOM en una fuente XML o HTML.
Propiedades
Esta interface hereda propiedades de EventTarget interface e implementa propiedades de WindowTimers y WindowBase64.
Nota que la propiedades que son objetos (por ejemplo para sobreescribir los prototipos de los elementos built-in) son descritos en una sección separada más abajo.
Window.applicationCacheRead only-
An
OfflineResourceListobject providing access to the offline resources for the window. Window.closedRead only-
Esta propiedad indica si la actual ventana esta cerrada o abierta.
Window.Components-
El punto de acceso a muchas propiedades XPCOM. Algunas propiedades, ej. classes, son disponibles solamente a codigo suficientemente privilegiado. El codigo Web no deberia usar esta propiedad.
Window.consoleRead only-
Retorna una referencia al objeto de la consola proveyendo acceso a la consola debugger del navegador.
Window.contentand Window.content Read only-
Returns a reference to the content element in the current window. The obsolete variant with underscore is no longer available from Web content.
Window.controllersRead only-
Returns the XUL controller objects for the current chrome window.
Window.cryptoRead only-
Returns the browser crypto object.
Window.defaultStatus-
Gets/sets the status bar text for the given window.
Window.devicePixelRatioRead only-
Returns the ratio between physical pixels and device independent pixels in the current display.
Window.dialogArgumentsRead only-
Gets the arguments passed to the window (if it's a dialog box) at the time
window.showModalDialog()was called. This is annsIArray. Window.directories-
Sinonimo de
window.personalbar Window.documentRead only-
Retorna una referencia al documento que esa ventana contiene.
Window.frameElementRead only-
Returns the element in which the window is embedded, or null if the window is not embedded.
Window.framesRead only-
Returns an array of the subframes in the current window.
Window.fullScreen-
Esta propiedad indica si la ventana esta desplegada en pantalla completa o no.
window.globalStorage-
Unsupported since Gecko 13 (Firefox 13). Use
Window.localStorageinstead. Was: Multiple storage objects that are used for storing data across multiple pages. Window.historyRead only-
Retorna una referencia a la historia del objeto.
Window.innerHeight-
Obtiene la altura del area de contenido del navegador incluyendo, si es interpretado, la barra de deslizado.
window.innerWidth-
Obtiene el ancho del area de contenido de la ventana del navegador, si es interpretado, la barra de deslizado vertical.
Window.lengthRead only-
Retorna el numero de marcos en la ventana. Ver tambien
window.frames. Window.locationRead only-
Obtiene/fija la location, o URL actual, del objeto de la ventana.
Window.locationbarRead only-
Retorna el objeto locationbar, cuya visibilidad puede ser fijada en la ventana.
Window.localStorageRead only-
Retorna una referencia al objeto almacenamiento local usado para almacenar datos que pueden ser de accedidos por el origen que los creo.
-
Retorna el objeto barra de menu, cuya visibilidad puede ser fijada en la ventana.
Window.messageManager-
Retorna el objeto message manager para esta ventana.
Window.mozAnimationStartTimeRead only-
The time in milliseconds since epoch at which the current animation cycle began.
Window.mozInnerScreenXRead only-
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. See
mozScreenPixelsPerCSSPixelinnsIDOMWindowUtilsfor a conversion factor to adapt to screen pixels if needed. Window.mozInnerScreenYRead only-
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. See
mozScreenPixelsPerCSSPixelfor a conversion factor to adapt to screen pixels if needed. Window.mozPaintCountRead only-
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-
Gets/sets the name of the window.
-
Returns a reference to the navigator object.
Window.opener-
Returns a reference to the window that opened this current window.
Window.outerHeightRead only-
Gets the height of the outside of the browser window.
Window.outerWidthRead only-
Gets the width of the outside of the browser window.
Window.pageXOffsetRead only-
An alias for
window.scrollX. Window.pageYOffsetRead only-
An alias for
window.scrollY Window.sessionStorageRead only-
Returns a reference to the session storage object used to store data that may only be accessed by the origin that created it.
SpeechSynthesisGetter.speechSynthesisRead only-
Returns a
SpeechSynthesisobject, which is the entry point into using Web Speech API speech synthesis functionality. Window.parentRead only-
Returns a reference to the parent of the current window or subframe.
Window.performanceRead only-
Provides a hosting area for performance related attributes.
Window.personalbarRead only-
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 called
window.showModalDialog()to display the window as a modal dialog. Window.screenRead only-
Returns a reference to the screen object associated with the window.
Window.screenXRead only-
Returns the horizontal distance of the left border of the user's browser from the left side of the screen.
Window.screenYRead only-
Returns the vertical distance of the top border of the user's browser from the top side of the screen.
Window.scrollbarsRead only-
Returns the scrollbars object, whose visibility can be toggled in the window.
Window.scrollMaxXRead only-
The maximum offset that the window can be scrolled to horizontally, that is the document width minus the viewport width.
Window.scrollMaxYRead only-
The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height).
Window.scrollXRead only-
Returns the number of pixels that the document has already been scrolled horizontally.
Window.scrollYRead only-
Returns the number of pixels that the document has already been scrolled vertically.
Window.selfRead only-
Returns an object reference to the window object itself.
Window.sessionStorage-
Returns a storage object for storing data within a single page session.
-
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.statusbarRead only-
Returns the statusbar object, whose visibility can be toggled in the window.
Window.toolbarRead only-
Returns the toolbar object, whose visibility can be toggled in the window.
Window.topRead only-
Returns a reference to the topmost window in the window hierarchy. This property is read only.
Window.windowRead only-
Returns a reference to the current window.
window[0],window[1], etc.-
Returns a reference to the
windowobject in the frames. SeeWindow.framesfor more details.
Methods
Esta interfaz hereda metodos de la interfaz EventTarget e implementa metodos WindowTimers y WindowBase64.
EventTarget.addEventListener()-
Registra un controlador de eventos a un tipo de evento especifico en la ventana.
Window.alert()