deno.com

interface Window

extends EventTarget

Represents the global window object in the Deno runtime environment.

While Deno doesn't have a browser window, this interface mimics browser window functionality for compatibility with web APIs. It provides access to global properties and methods such as timers, storage, and event handling.

Examples #

#
// Accessing global objects
const localStorage = window.localStorage;

// Event handling
window.addEventListener("unhandledrejection", (event) => {
  console.log("Unhandled promise rejection:", event.reason);d
});

Properties #

#window: Window & globalThis
readonly
#self: Window & globalThis
readonly
#onerror: ((
this: Window,
) => any) | null
#onload: ((
this: Window,
ev: Event,
) => any) | null
#onbeforeunload: ((
this: Window,
ev: Event,
) => any) | null
#onunload: ((
this: Window,
ev: Event,
) => any) | null
#onunhandledrejection: (() => any) | null
#onrejectionhandled: (() => any) | null
#close: () => void
#closed: boolean
readonly
#alert: (message?: string) => void
#confirm: (message?: string) => boolean
#prompt: (
message?: string,
defaultValue?: string,
) => string | null
#Deno: Deno
#name: string

Methods #

#addEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (
this: Window,
) => any
,
options?: boolean | AddEventListenerOptions,
): void
#addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
#removeEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (
this: Window,
) => any
,
options?: boolean | EventListenerOptions,
): void
#removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void

variable Window

Constructor for Window objects.

Note: This constructor cannot be used to create new Window instances in Deno. The global window object is pre-defined in the runtime environment.

Properties #

#prototype: Window
readonly