---
name: "up.viewport.restoreFocus"
area: "API"
kind: "JavaScript function"
parent: "up.viewport module"
url: "https://unpoly.com/api/up.viewport.restoreFocus"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.viewport module](https://unpoly.com/api/up.viewport.md)</nav>

# up.viewport.restoreFocus([options])

Restores [previously saved](https://unpoly.com/api/up.viewport.saveFocus.md) focus-related state.

Unpoly automatically restores focus-related state when the user [presses the back button](https://unpoly.com/learn/restoring-history.md).

---

## Parameters {#parameters}

### [options.layer='current'] {#options.layer}

(optional)

The layer on which to restore focus-related state.

Type: [up.Layer](https://unpoly.com/api/up.Layer.md) | string

### [options.location] {#options.location}

(optional)

The URL for which to restore focus-related state.

If omitted, the given [layer's location](https://unpoly.com/api/up.Layer.prototype.location.md) is used.

Type: string

---

## Return value {#return-value}

Returns whether focus state could be restored.

Type: boolean

