Edit this page

up.viewport up.viewport.saveScroll([viewport], [options])
JavaScript function

This feature is experimental. It may be changed or removed in a future version.

Saves scroll positions for later restoration.

The scroll positions will be associated with the current URL. They can later be restored by calling up.viewport.restoreScroll() at the same URL, or by following a link with an [up-scroll="restore"] attribute.

Unpoly automatically saves scroll positions before navigating.


Parameters

[viewport] ElementorArray<Element> optional

The viewports for which to save scroll positions.

Defaults to all viewports within the given layer.

[options.location] string optional

The URL for which to save scroll positions.

If omitted, the given layer's location is used.

[options.layer='current'] string optional

The layer for which to save scroll positions.

If omitted, positions for the current layer will be saved.