# WebWindow

**Kind**: interface | **Module**: [Windows](https://docs.interop.io/browser/reference/javascript/windows/index.md)

**Source**: https://docs.interop.io/browser/reference/javascript/windows/webwindow/index.html

## Properties

- **`id`** (`string`, required)
  ID of the window.
- **`isFocused`** (`boolean`, required)
  Flag indicating whether the window is currently on focus.
- **`name`** (`string`, required)
  Name of the window.
- **`zoomFactor`** (`number`, required)
  Retrieves the current zoom factor.

## Methods

### close

Closes the window

```ts
() => Promise<WebWindow>
```

**Returns**: `Promise<WebWindow>`

### focus

Attempts to activate and bring to foreground the window. It is possible to fail due to client browser settings.

```ts
() => Promise<WebWindow>
```

**Returns**: `Promise<WebWindow>`

### getBounds

Returns the current location and size of the window.

```ts
() => Promise<Bounds>
```

**Returns**: `Promise<Bounds>`

### getChannel

Retrieves the current Channel of the window, if any.

```ts
() => Promise<string>
```

**Returns**: `Promise<string>`

### getContext

Gets the current context object of the window.

```ts
() => Promise<any>
```

**Returns**: `Promise<any>`

### getTitle

Returns the title of the window.

```ts
() => Promise<string>
```

**Returns**: `Promise<string>`

### getURL

Gets the current URL of the window.

```ts
() => Promise<string>
```

**Returns**: `Promise<string>`

### moveResize

Sets new location and size for the window. The accepted settings are absolute.

```ts
(dimension: Partial<Bounds>) => Promise<WebWindow>
```

**Parameters**

- **`dimension`** (`Partial<Bounds>`, required)
  The object containing the desired absolute size and location.

**Returns**: `Promise<WebWindow>`

### moveTo

Sets a new location of the window. The accepted settings are relative.

```ts
(top?: number, left?: number) => Promise<WebWindow>
```

**Parameters**

- **`top`** (`number`, optional)
  Relative distance top coordinates.
- **`left`** (`number`, optional)
  Relative distance left coordinates.

**Returns**: `Promise<WebWindow>`

### onChannelsChanged

Notifies when the current Channels of the window have changed. Returns a function you can use to unsubscribe from the event.

```ts
(callback: (names: string[]) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(names: string[]) => void`, required)
  Callback for handling the event. Receives the names of the current Channels as an argument.

**Returns**: `UnsubscribeFunction`

### onContextUpdated

Notifies when a change to the window's context has been made.

```ts
(callback: (context: any, window: WebWindow) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(context: any, window: WebWindow) => void`, required)
  The function which will be invoked when a change to the window's context happens. The function will be called with the new context and window as arguments.

**Returns**: `UnsubscribeFunction`

### onFocusChanged

Notifies when the window focus is changed.

```ts
(callback: (window: WebWindow) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(window: WebWindow) => void`, required)
  Callback function to handle the event. Returns an unsubscribe function.

**Returns**: `UnsubscribeFunction`

### onZoomFactorChanged

Notifies when the zoom factor is changed.

*Since: io.Connect Browser 4.1*

```ts
(callback: (window: WebWindow) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(window: WebWindow) => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### refresh

Refreshes the current window.

*Since: io.Connect Browser 4.1*

```ts
() => Promise<WebWindow>
```

**Returns**: `Promise<WebWindow>`

### resizeTo

Sets a new size of the window. The accepted settings are relative.

```ts
(width?: number, height?: number) => Promise<WebWindow>
```

**Parameters**

- **`width`** (`number`, optional)
  Relative width of the window.
- **`height`** (`number`, optional)
  Relative height of the window.

**Returns**: `Promise<WebWindow>`

### setContext

Sets new context for the window.

```ts
(context: any) => Promise<WebWindow>
```

**Parameters**

- **`context`** (`any`, required)
  The new context object for the window.

**Returns**: `Promise<WebWindow>`

### setTitle

Sets a new title for the window

```ts
(title: string) => Promise<WebWindow>
```

**Parameters**

- **`title`** (`string`, required)
  The new title value.

**Returns**: `Promise<WebWindow>`

### setZoomFactor

Changes the zoom level.

*Since: io.Connect Browser 4.1*

```ts
(factor: number) => Promise<WebWindow>
```

**Parameters**

- **`factor`** (`number`, required)
  Zoom factor.

**Returns**: `Promise<WebWindow>`

### updateContext

Updates the context object of the window

```ts
(context: any) => Promise<WebWindow>
```

**Parameters**

- **`context`** (`any`, required)
  The new context object for the window.

**Returns**: `Promise<WebWindow>`

### zoomIn

Zooms in the window.

*Since: io.Connect Browser 4.1*

```ts
() => Promise<WebWindow>
```

**Returns**: `Promise<WebWindow>`

### zoomOut

Zooms out the window.

*Since: io.Connect Browser 4.1*

```ts
() => Promise<WebWindow>
```

**Returns**: `Promise<WebWindow>`

## Related types

- [Bounds](https://docs.interop.io/browser/reference/javascript/windows/bounds/index.md)
- [UnsubscribeFunction](https://docs.interop.io/browser/reference/javascript/search/unsubscribefunction/index.md)
