Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Window

A window containing a DOM document; the document property points to the DOM document loaded in that window.

interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandlers, WindowEventHandlers, WindowLocalStorage, WindowOrWorkerGlobalScope, WindowSessionStorage {
[index: number]: Window;
readonly clientInformation: Navigator;
readonly closed: boolean;
readonly customElements: CustomElementRegistry;
readonly devicePixelRatio: number;
readonly document: Document;
readonly event: Event | undefined;
readonly external: External;
readonly frameElement: Element | null;
readonly frames: WindowProxy;
readonly history: History;
readonly innerHeight: number;
readonly innerWidth: number;
readonly length: number;
readonly locationbar: BarProp;
readonly menubar: BarProp;
name: string;
readonly navigator: Navigator;
ondevicemotion: ((this: Window, ev: DeviceMotionEvent) => any) | null;
ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => any) | null;
onorientationchange: ((this: Window, ev: Event) => any) | null;
opener: any;
readonly orientation: number;
readonly outerHeight: number;
readonly outerWidth: number;
readonly pageXOffset: number;
readonly pageYOffset: number;
readonly parent: WindowProxy;
readonly personalbar: BarProp;
readonly screen: Screen;
readonly screenLeft: number;
readonly screenTop: number;
readonly screenX: number;
readonly screenY: number;
readonly scrollbars: BarProp;
readonly scrollX: number;
readonly scrollY: number;
readonly self: Window & globalThis;
readonly speechSynthesis: SpeechSynthesis;
status: string;
readonly statusbar: BarProp;
readonly toolbar: BarProp;
readonly top: WindowProxy | null;
readonly visualViewport: VisualViewport | null;
readonly window: Window & globalThis;
addEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (this: Window, ev: WindowEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void;
alert(message?: any): void;
blur(): void;
cancelIdleCallback(handle: number): void;
captureEvents(): void;
close(): void;
confirm(message?: string): boolean;
focus(): void;
getComputedStyle(elt: Element, pseudoElt?: string | null): CSSStyleDeclaration;
getSelection(): Selection | null;
get location(): Location;
set location(href: string | Location);
matchMedia(query: string): MediaQueryList;
moveBy(x: number, y: number): void;
moveTo(x: number, y: number): void;
open(
url?: string | URL,
target?: string,
features?: string,
): WindowProxy | null;
postMessage(
message: any,
targetOrigin: string,
transfer?: Transferable[],
): void;
postMessage(message: any, options?: WindowPostMessageOptions): void;
print(): void;
prompt(message?: string, _default?: string): string | null;
releaseEvents(): void;
removeEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (this: Window, ev: WindowEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void;
requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number;
resizeBy(x: number, y: number): void;
resizeTo(width: number, height: number): void;
scroll(options?: ScrollToOptions): void;
scroll(x: number, y: number): void;
scrollBy(options?: ScrollToOptions): void;
scrollBy(x: number, y: number): void;
scrollTo(options?: ScrollToOptions): void;
scrollTo(x: number, y: number): void;
stop(): void;
}
var Window: {
prototype: Window;
new (): Window;
}
;

§Extends

§Index Signatures

§
[index: number]: Window

§Properties

§
readonly clientInformation: Navigator
[src]
§
readonly closed: boolean
[src]

Returns true if the window has been closed, false otherwise.

§
readonly customElements: CustomElementRegistry
[src]

Defines a new custom element, mapping the given name to the given constructor as an autonomous custom element.

§
readonly devicePixelRatio: number
[src]
§
readonly document: Document
[src]
§
readonly event: Event | undefined
[src]
§
readonly external: External
[src]
§
readonly frameElement: Element | null
[src]
§
readonly frames: WindowProxy
[src]
§
readonly history: History
[src]
§
readonly innerHeight: number
[src]
§
readonly innerWidth: number
[src]
§
readonly length: number
[src]
§
readonly locationbar: BarProp
[src]

Returns true if the location bar is visible; otherwise, returns false.

§
name: string
[src]
§
ondevicemotion: ((this: Window, ev: DeviceMotionEvent) => any) | null
[src]

Available only in secure contexts.

§
ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => any) | null
[src]

Available only in secure contexts.

§
onorientationchange: ((this: Window, ev: Event) => any) | null
[src]
§
opener: any
[src]
§
readonly orientation: number
[src]
§
readonly outerHeight: number
[src]
§
readonly outerWidth: number
[src]
§
readonly pageXOffset: number
[src]
§
readonly pageYOffset: number
[src]
§
readonly parent: WindowProxy
[src]

Refers to either the parent WindowProxy, or itself.

It can rarely be null e.g. for contentWindow of an iframe that is already removed from the parent.

§
readonly personalbar: BarProp
[src]

Returns true if the personal bar is visible; otherwise, returns false.

§
readonly screen: Screen
[src]
§
readonly screenLeft: number
[src]
§
readonly screenTop: number
[src]
§
readonly screenX: number
[src]
§
readonly screenY: number
[src]
§
readonly scrollbars: BarProp
[src]

Returns true if the scrollbars are visible; otherwise, returns false.

§
readonly scrollX: number
[src]
§
readonly scrollY: number
[src]
§
readonly self: Window & globalThis
[src]
§
readonly speechSynthesis: SpeechSynthesis
[src]
§
status: string
[src]
§
readonly statusbar: BarProp
[src]

Returns true if the status bar is visible; otherwise, returns false.

§
readonly toolbar: BarProp
[src]

Returns true if the toolbar is visible; otherwise, returns false.

§
readonly top: WindowProxy | null
[src]
§
readonly visualViewport: VisualViewport | null
[src]
§
readonly window: Window & globalThis
[src]

§Methods

§
addEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (this: Window, ev: WindowEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void
[src]
§
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
[src]
§
alert(message?: any): void
[src]
§
blur(): void
[src]
§
cancelIdleCallback(handle: number): void
[src]
§
captureEvents(): void
[src]
§
close(): void
[src]

Closes the window.

§
confirm(message?: string): boolean
[src]
§
focus(): void
[src]

Moves the focus to the window's browsing context, if any.

§
getComputedStyle(elt: Element, pseudoElt?: string | null): CSSStyleDeclaration
[src]
§
getSelection(): Selection | null
[src]
§
get location(): Location
[src]
§
set location(href: string | Location)
[src]
§
matchMedia(query: string): MediaQueryList
[src]
§
moveBy(x: number, y: number): void
[src]
§
moveTo(x: number, y: number): void
[src]
§
open(
url?: string | URL,
target?: string,
features?: string,
): WindowProxy | null
[src]
§
postMessage(
message: any,
targetOrigin: string,
transfer?: Transferable[],
): void
[src]

Posts a message to the given window. Messages can be structured objects, e.g. nested objects and arrays, can contain JavaScript values (strings, numbers, Date objects, etc), and can contain certain data objects such as File Blob, FileList, and ArrayBuffer objects.

Objects listed in the transfer member of options are transferred, not just cloned, meaning that they are no longer usable on the sending side.

A target origin can be specified using the targetOrigin member of options. If not provided, it defaults to "/". This default restricts the message to same-origin targets only.

If the origin of the target window doesn't match the given target origin, the message is discarded, to avoid information leakage. To send the message to the target regardless of origin, set the target origin to "*".

Throws a "DataCloneError" DOMException if transfer array contains duplicate objects or if message could not be cloned.

§
postMessage(message: any, options?: WindowPostMessageOptions): void
[src]
§
print(): void
[src]
§
prompt(message?: string, _default?: string): string | null
[src]
§
releaseEvents(): void
[src]
§
removeEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (this: Window, ev: WindowEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
[src]
§
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void
[src]
§
requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number
[src]
§
resizeBy(x: number, y: number): void
[src]
§
resizeTo(width: number, height: number): void
[src]
§
scroll(options?: ScrollToOptions): void
[src]
§
scroll(x: number, y: number): void
[src]
§
scrollBy(options?: ScrollToOptions): void
[src]
§
scrollBy(x: number, y: number): void
[src]
§
scrollTo(options?: ScrollToOptions): void
[src]
§
scrollTo(x: number, y: number): void
[src]
§
stop(): void
[src]

Cancels the document load.