Skip to main content

Class: abstract Window

Defined in: packages/core/src/window/Window.ts:36

The Window interface defines various utility API for easier cross-environment usage of various low-level client-side JavaScript APIs available through various global objects.

Extended by

Constructors

new Window()

new Window(): Window

Returns

Window

Methods

bindEventListener()

Call Signature

bindEventListener<T, K, S>(eventTarget, event, listener, options?, scope?): void

Defined in: packages/core/src/window/Window.ts:310

Registers the provided event listener to be executed when the specified event occurs on the specified event target.

Registering the same event listener for the same event on the same event target with the same useCapture flag value repeatedly has no effect.

Type Parameters

T extends WindowEventTargets

K extends string | number | symbol

S = any

Parameters
eventTarget

T

The event target.

event

K

The name of the event.

listener

(event) => void

The event listener.

options?

boolean | EventListenerOptions

scope?

S

Returns

void

Call Signature

bindEventListener<T, E, S>(eventTarget, event, listener, options?, scope?): void

Defined in: packages/core/src/window/Window.ts:321

Registers the provided event listener to be executed when the specified event occurs on the specified event target.

Registering the same event listener for the same event on the same event target with the same useCapture flag value repeatedly has no effect.

Type Parameters

T extends EventTarget

E extends Event = Event

S = any

Parameters
eventTarget

T

The event target.

event

string

The name of the event.

listener

(event) => void

The event listener.

options?

boolean | EventListenerOptions

scope?

S

Returns

void


createCustomEvent()

createCustomEvent<T>(name, options): CustomEvent<T>

Defined in: packages/core/src/window/Window.ts:265

Create new instance of CustomEvent of the specified name and using the provided options.

Type Parameters

T

Parameters

name

string

Custom event's name (sometimes referred to as the event's type).

options

CustomEventInit<T>

The custom event's options.

Returns

CustomEvent<T>

The created custom event.

See

https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent


getBody()

getBody(): undefined | HTMLElement

Defined in: packages/core/src/window/Window.ts:168

Returns the document's body element. The method returns undefined if invoked at the server-side.

Returns

undefined | HTMLElement

The document's body element, or undefined if invoked at the server side.


getDocument()

getDocument(): undefined | Document

Defined in: packages/core/src/window/Window.ts:94

Returns the native document object representing any web page loaded in the browser and serves as an entry point into the web page's content which is the DOM tree at the client-side. The method returns undefined if used at the server-side.

Returns

undefined | Document

The document object at the client-side, or undefined at the server-side.


getDomain()

getDomain(): string

Defined in: packages/core/src/window/Window.ts:134

Returns the domain of the current document's URL as ${protocol}://${host}.

Returns

string

The current domain.


getElementById()

getElementById(id): null | HTMLElement

Defined in: packages/core/src/window/Window.ts:179

Returns the HTML element with the specified id attribute value.

Parameters

id

string

The value of the id attribute to look for.

Returns

null | HTMLElement

The element with the specified id, or null if no such element exists.


getHistoryState()

getHistoryState(): any

Defined in: packages/core/src/window/Window.ts:188

Returns the history state.

Returns

any

The current history state


getHost()

getHost(): string

Defined in: packages/core/src/window/Window.ts:141

Returns

string

The current host.


getPath()

getPath(): string

Defined in: packages/core/src/window/Window.ts:150

Returns the path part of the current URL, including the query string.

Returns

string

The path and query string parts of the current URL.


getScrollX()

getScrollX(): number

Defined in: packages/core/src/window/Window.ts:104

Returns the number of pixels the viewport is scrolled horizontally.

Returns

number

The number of pixels the viewport is scrolled horizontally.


getScrollY()

getScrollY(): number

Defined in: packages/core/src/window/Window.ts:114

Returns the number of pixels the document is scrolled vertically.

Returns

number

The number of pixels the document is scrolled vertically.


getUrl()

getUrl(): string

Defined in: packages/core/src/window/Window.ts:157

Returns

string

The current document's URL.


getWindow()

getWindow(): undefined | Window

Defined in: packages/core/src/window/Window.ts:81

Returns the native window object representing the global context at the client-side. The method returns undefined if used at the server-side.

Returns

undefined | Window

The window object at the client-side, or undefined at the server-side.


hasSessionStorage()

hasSessionStorage(): boolean

Defined in: packages/core/src/window/Window.ts:60

Returns true if the session storage is supported.

Returns

boolean

true if the session storage is supported.


isClient()

isClient(): boolean

Defined in: packages/core/src/window/Window.ts:40

Returns

boolean

true if invoked at the client side.


isCookieEnabled()

isCookieEnabled(): boolean

Defined in: packages/core/src/window/Window.ts:51

Returns true if the cookies are set and processed with every HTTP request and response automatically by the environment.

Returns

boolean

true if cookies are handled automatically by the environment.


pushState()

pushState<T>(state, title, url?): void

Defined in: packages/core/src/window/Window.ts:237

Pushes a new state to the browser history. The method has no effect if the current browser does not support the history API (IE9).

Type Parameters

T

Parameters

state

T

A state object associated with the history item, preferably representing the page state.

title

string

The page title related to the state. Note that this parameter is ignored by some browsers.

url?

string

The new URL at which the state is available.

Returns

void


querySelector()

querySelector<E>(selector): null | E

Defined in: packages/core/src/window/Window.ts:199

Returns the first element matching the specified CSS 3 selector.

Type Parameters

E extends Element = Element

Parameters

selector

string

The CSS selector.

Returns

null | E

The first element matching the CSS selector or null if no such element exists.


querySelectorAll()

querySelectorAll<E>(selector): NodeListOf<E>

Defined in: packages/core/src/window/Window.ts:211

Returns a node list of all elements matching the specified CSS 3 selector.

Type Parameters

E extends Element = Element

Parameters

selector

string

The CSS selector.

Returns

NodeListOf<E>

A node list containing all elements matching the specified CSS selector.


redirect()

redirect(url): void

Defined in: packages/core/src/window/Window.ts:223

Performs a hard redirect (discarding the current JavaScript state) to the specified URL.

Parameters

url

string

The URL to which the browser will be redirected.

Returns

void


replaceState()

replaceState<T>(state, title, url?): void

Defined in: packages/core/src/window/Window.ts:251

Replaces the current history entry. The method has no effect if the current browser does not support the history API (IE9).

Type Parameters

T

Parameters

state

T

A state object associated with the history item, preferably representing the page state.

title

string

The page title related to the state. Note that this parameter is ignored by some browsers.

url?

string

The new URL at which the state is available.

Returns

void


scrollTo()

scrollTo(x, y): void

Defined in: packages/core/src/window/Window.ts:124

Scrolls the viewport to the specified location (if possible).

Parameters

x

number

Horizontal scroll offset in pixels.

y

number

Vertical scroll offset in pixels.

Returns

void


setTitle()

setTitle(title): void

Defined in: packages/core/src/window/Window.ts:69

Sets the new page title of the document.

Parameters

title

string

The new page title.

Returns

void


unbindEventListener()

Call Signature

unbindEventListener<T, K, S>(eventTarget, event, listener, options?, scope?): void

Defined in: packages/core/src/window/Window.ts:345

Deregister the provided event listener, so it will no longer we executed when the specified event occurs on the specified event target.

The method has no effect if the provided event listener is not registered to be executed at the specified event.

Type Parameters

T extends WindowEventTargets

K extends string | number | symbol

S

Parameters
eventTarget

T

The event target.

event

K

The name of the event.

listener

(event) => void

The event listener.

options?

The useCapture flag value that was used when the listener was registered, or provide capture option through object options.

boolean | EventListenerOptions

scope?

S

Returns

void

Call Signature

unbindEventListener<T, E, S>(eventTarget, event, listener, options?, scope?): void

Defined in: packages/core/src/window/Window.ts:356

Deregister the provided event listener, so it will no longer we executed when the specified event occurs on the specified event target.

The method has no effect if the provided event listener is not registered to be executed at the specified event.

Type Parameters

T extends EventTarget

E extends Event = Event

S = any

Parameters
eventTarget

T

The event target.

event

string

The name of the event.

listener

(event) => void

The event listener.

options?

The useCapture flag value that was used when the listener was registered, or provide capture option through object options.

boolean | EventListenerOptions

scope?

S

Returns

void