Join us online - 19th of November
Save your spot
For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Interface Window

The Window interface represents a window containing a DOM document; the document property points to the DOM document loaded in that window.

MDN Reference

interface Window {
    caches: CacheStorage;
    clientInformation: Navigator;
    closed: boolean;
    cookieStore: CookieStore;
    crossOriginIsolated: boolean;
    crypto: Crypto;
    customElements: CustomElementRegistry;
    devicePixelRatio: number;
    document: Document;
    event: Event | undefined;
    external: External;
    frameElement: Element | null;
    frames: Window;
    history: History;
    indexedDB: IDBFactory;
    innerHeight: number;
    innerWidth: number;
    isSecureContext: boolean;
    length: number;
    localStorage: Storage;
    locationbar: BarProp;
    menubar: BarProp;
    name: string;
    navigation: Navigation;
    navigator: Navigator;
    onabort: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
    onafterprint: ((this: WindowEventHandlers, ev: Event) => any) | null;
    onanimationcancel:
        | ((this: GlobalEventHandlers, ev: AnimationEvent) => any)
        | null;
    onanimationend:
        | ((this: GlobalEventHandlers, ev: AnimationEvent) => any)
        | null;
    onanimationiteration:
        | ((this: GlobalEventHandlers, ev: AnimationEvent) => any)
        | null;
    onanimationstart:
        | ((this: GlobalEventHandlers, ev: AnimationEvent) => any)
        | null;
    onauxclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
    onbeforeinput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
    onbeforematch: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onbeforeprint: ((this: WindowEventHandlers, ev: Event) => any) | null;
    onbeforetoggle:
        | ((this: GlobalEventHandlers, ev: ToggleEvent) => any)
        | null;
    onbeforeunload:
        | ((this: WindowEventHandlers, ev: BeforeUnloadEvent) => any)
        | null;
    onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
    oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
    onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    oncommand: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    oncontextmenu:
        | ((this: GlobalEventHandlers, ev: PointerEvent) => any)
        | null;
    oncontextrestored: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    oncopy: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
    oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    oncut: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
    ondblclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
    ondevicemotion: ((this: Window, ev: DeviceMotionEvent) => any) | null;
    ondeviceorientation:
        | ((this: Window, ev: DeviceOrientationEvent) => any)
        | null;
    ondeviceorientationabsolute:
        | ((this: Window, ev: DeviceOrientationEvent) => any)
        | null;
    ondrag: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
    ondragend: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
    ondragenter: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
    ondragleave: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
    ondragover: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
    ondragstart: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
    ondrop: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
    ondurationchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onemptied: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onended: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onerror: OnErrorEventHandler;
    onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
    onformdata: ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | null;
    ongamepadconnected:
        | ((this: WindowEventHandlers, ev: GamepadEvent) => any)
        | null;
    ongamepaddisconnected:
        | ((this: WindowEventHandlers, ev: GamepadEvent) => any)
        | null;
    ongotpointercapture:
        | ((this: GlobalEventHandlers, ev: PointerEvent) => any)
        | null;
    onhashchange:
        | ((this: WindowEventHandlers, ev: HashChangeEvent) => any)
        | null;
    oninput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
    oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onkeydown: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
    onkeypress: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
    onkeyup: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
    onlanguagechange: ((this: WindowEventHandlers, ev: Event) => any) | null;
    onload: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onloadeddata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onloadedmetadata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onloadstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onlostpointercapture:
        | ((this: GlobalEventHandlers, ev: PointerEvent) => any)
        | null;
    onmessage: ((this: WindowEventHandlers, ev: MessageEvent) => any) | null;
    onmessageerror:
        | ((this: WindowEventHandlers, ev: MessageEvent) => any)
        | null;
    onmousedown: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
    onmouseenter: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
    onmouseleave: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
    onmousemove: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
    onmouseout: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
    onmouseover: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
    onmouseup: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
    onoffline: ((this: WindowEventHandlers, ev: Event) => any) | null;
    ononline: ((this: WindowEventHandlers, ev: Event) => any) | null;
    onorientationchange: ((this: Window, ev: Event) => any) | null;
    onpagehide:
        | ((this: WindowEventHandlers, ev: PageTransitionEvent) => any)
        | null;
    onpagereveal:
        | ((this: WindowEventHandlers, ev: PageRevealEvent) => any)
        | null;
    onpageshow:
        | ((this: WindowEventHandlers, ev: PageTransitionEvent) => any)
        | null;
    onpageswap: ((this: WindowEventHandlers, ev: PageSwapEvent) => any) | null;
    onpaste: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
    onpause: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onplaying: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onpointercancel:
        | ((this: GlobalEventHandlers, ev: PointerEvent) => any)
        | null;
    onpointerdown:
        | ((this: GlobalEventHandlers, ev: PointerEvent) => any)
        | null;
    onpointerenter:
        | ((this: GlobalEventHandlers, ev: PointerEvent) => any)
        | null;
    onpointerleave:
        | ((this: GlobalEventHandlers, ev: PointerEvent) => any)
        | null;
    onpointermove:
        | ((this: GlobalEventHandlers, ev: PointerEvent) => any)
        | null;
    onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
    onpointerover:
        | ((this: GlobalEventHandlers, ev: PointerEvent) => any)
        | null;
    onpointerrawupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
    onpopstate: ((this: WindowEventHandlers, ev: PopStateEvent) => any) | null;
    onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null;
    onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onrejectionhandled:
        | ((this: WindowEventHandlers, ev: PromiseRejectionEvent) => any)
        | null;
    onreset: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onresize: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
    onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onscrollend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onsecuritypolicyviolation:
        | (
            (this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any
        )
        | null;
    onseeked: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onseeking: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onselect: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onselectionchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onselectstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onslotchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onstalled: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onstorage: ((this: WindowEventHandlers, ev: StorageEvent) => any) | null;
    onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null;
    onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    ontoggle: ((this: GlobalEventHandlers, ev: ToggleEvent) => any) | null;
    ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
    ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
    ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
    ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null;
    ontransitioncancel:
        | ((this: GlobalEventHandlers, ev: TransitionEvent) => any)
        | null;
    ontransitionend:
        | ((this: GlobalEventHandlers, ev: TransitionEvent) => any)
        | null;
    ontransitionrun:
        | ((this: GlobalEventHandlers, ev: TransitionEvent) => any)
        | null;
    ontransitionstart:
        | ((this: GlobalEventHandlers, ev: TransitionEvent) => any)
        | null;
    onunhandledrejection:
        | ((this: WindowEventHandlers, ev: PromiseRejectionEvent) => any)
        | null;
    onunload: ((this: WindowEventHandlers, ev: Event) => any) | null;
    onvolumechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onwaiting: ((this: GlobalEventHandlers, ev: Event) => any) | null;
    onwebkitanimationend:
        | ((this: GlobalEventHandlers, ev: Event) => any)
        | null;
    onwebkitanimationiteration:
        | ((this: GlobalEventHandlers, ev: Event) => any)
        | null;
    onwebkitanimationstart:
        | ((this: GlobalEventHandlers, ev: Event) => any)
        | null;
    onwebkittransitionend:
        | ((this: GlobalEventHandlers, ev: Event) => any)
        | null;
    onwheel: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null;
    opener: any;
    orientation: number;
    origin: string;
    originAgentCluster: boolean;
    outerHeight: number;
    outerWidth: number;
    pageXOffset: number;
    pageYOffset: number;
    parent: Window;
    performance: Performance;
    personalbar: BarProp;
    scheduler: Scheduler;
    screen: Screen;
    screenLeft: number;
    screenTop: number;
    screenX: number;
    screenY: number;
    scrollbars: BarProp;
    scrollX: number;
    scrollY: number;
    self: Window & typeof globalThis;
    sessionStorage: Storage;
    speechSynthesis: SpeechSynthesis;
    status: string;
    statusbar: BarProp;
    toolbar: BarProp;
    top: Window | null;
    visualViewport: VisualViewport | null;
    window: Window & typeof globalThis;
    get location(): Location;
    set location(href: string): void;
    addEventListener<K extends keyof WindowEventMap>(
        type: K,
        listener: (this: Window, ev: WindowEventMap[K]) => any,
        options?: boolean | AddEventListenerOptions,
    ): void;
    addEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | AddEventListenerOptions,
    ): void;
    alert(message?: any): void;
    atob(data: string): string;
    blur(): void;
    btoa(data: string): string;
    cancelAnimationFrame(handle: number): void;
    cancelIdleCallback(handle: number): void;
    captureEvents(): void;
    clearInterval(id: number | undefined): void;
    clearTimeout(id: number | undefined): void;
    close(): void;
    confirm(message?: string): boolean;
    createImageBitmap(
        image: ImageBitmapSource,
        options?: ImageBitmapOptions,
    ): Promise<ImageBitmap>;
    createImageBitmap(
        image: ImageBitmapSource,
        sx: number,
        sy: number,
        sw: number,
        sh: number,
        options?: ImageBitmapOptions,
    ): Promise<ImageBitmap>;
    dispatchEvent(event: Event): boolean;
    fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
    focus(): void;
    getComputedStyle(
        elt: Element,
        pseudoElt?: string | null,
    ): CSSStyleDeclaration;
    getSelection(): Selection | null;
    matchMedia(query: string): MediaQueryList;
    moveBy(x: number, y: number): void;
    moveTo(x: number, y: number): void;
    open(url?: string | URL, target?: string, features?: string): Window | null;
    postMessage(
        message: any,
        targetOrigin: string,
        transfer?: Transferable[],
    ): void;
    postMessage(message: any, options?: WindowPostMessageOptions): void;
    print(): void;
    prompt(message?: string, _default?: string): string | null;
    queueMicrotask(callback: VoidFunction): void;
    releaseEvents(): void;
    removeEventListener<K extends keyof WindowEventMap>(
        type: K,
        listener: (this: Window, ev: WindowEventMap[K]) => any,
        options?: boolean | EventListenerOptions,
    ): void;
    removeEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | EventListenerOptions,
    ): void;
    reportError(e: any): void;
    requestAnimationFrame(callback: FrameRequestCallback): number;
    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;
    setInterval(
        handler: TimerHandler,
        timeout?: number,
        ...arguments: any[],
    ): number;
    setTimeout(
        handler: TimerHandler,
        timeout?: number,
        ...arguments: any[],
    ): number;
    stop(): void;
    structuredClone<T = any>(value: T, options?: StructuredSerializeOptions): T;
    [index: number]: Window;
}

Hierarchy (View Summary)

Indexable

Index
caches clientInformation closed cookieStore crossOriginIsolated crypto customElements devicePixelRatio document event external frameElement frames history indexedDB innerHeight innerWidth isSecureContext length localStorage locationbar menubar name navigation navigator onabort onafterprint onanimationcancel onanimationend onanimationiteration onanimationstart onauxclick onbeforeinput onbeforematch onbeforeprint onbeforetoggle onbeforeunload onblur oncancel oncanplay oncanplaythrough onchange onclick onclose oncommand oncontextlost oncontextmenu oncontextrestored oncopy oncuechange oncut ondblclick ondevicemotion ondeviceorientation ondeviceorientationabsolute ondrag ondragend ondragenter ondragleave ondragover ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformdata ongamepadconnected ongamepaddisconnected ongotpointercapture onhashchange oninput oninvalid onkeydown onkeypress onkeyup onlanguagechange onload onloadeddata onloadedmetadata onloadstart onlostpointercapture onmessage onmessageerror onmousedown onmouseenter onmouseleave onmousemove onmouseout onmouseover onmouseup onoffline ononline onorientationchange onpagehide onpagereveal onpageshow onpageswap onpaste onpause onplay onplaying onpointercancel onpointerdown onpointerenter onpointerleave onpointermove onpointerout onpointerover onpointerrawupdate onpointerup onpopstate onprogress onratechange onrejectionhandled onreset onresize onscroll onscrollend onsecuritypolicyviolation onseeked onseeking onselect onselectionchange onselectstart onslotchange onstalled onstorage onsubmit onsuspend ontimeupdate ontoggle ontouchcancel? ontouchend? ontouchmove? ontouchstart? ontransitioncancel ontransitionend ontransitionrun ontransitionstart onunhandledrejection onunload onvolumechange onwaiting onwebkitanimationend onwebkitanimationiteration onwebkitanimationstart onwebkittransitionend onwheel opener orientation origin originAgentCluster outerHeight outerWidth pageXOffset pageYOffset parent performance personalbar scheduler screen screenLeft screenTop screenX screenY scrollbars scrollX scrollY self sessionStorage speechSynthesis status statusbar toolbar top visualViewport window
caches: CacheStorage

Available only in secure contexts.

MDN Reference

clientInformation: Navigator

This is a legacy alias of navigator.

MDN Reference

closed: boolean

The Window.closed read-only property indicates whether the referenced window is closed or not.

MDN Reference

cookieStore: CookieStore

The cookieStore read-only property of the Window interface returns a reference to the CookieStore object for the current document context. This is an entry point for the Cookie Store API.

MDN Reference

crossOriginIsolated: boolean
crypto: Crypto
customElements: CustomElementRegistry

The customElements read-only property of the Window interface returns a reference to the CustomElementRegistry object, which can be used to register new custom elements and get information about previously registered custom elements.

MDN Reference

devicePixelRatio: number

The devicePixelRatio of Window interface returns the ratio of the resolution in physical pixels to the resolution in CSS pixels for the current display device.

MDN Reference

document: Document

window.document returns a reference to the document contained in the window.

MDN Reference

event: Event | undefined

The read-only Window property event returns the Event which is currently being handled by the site's code. Outside the context of an event handler, the value is always undefined.

MDN Reference

external: External

The external property of the Window API returns an instance of the External interface, which was intended to contain functions related to adding external search providers to the browser. However, this is now deprecated, and the contained methods are now dummy functions that do nothing as per spec.

MDN Reference

frameElement: Element | null

The Window.frameElement property returns the element (such as

Was this helpful?