Edit this page

up.history up:location:restore
DOM event

This event is emitted when the user is restoring a previous history entry, usually by pressing the back button.

Listeners may prevent up:location:restore and substitute their own restoration behavior:

up.on('up:location:restore', function(event) {
  event.preventDefault()
  document.body.innerText = `Restored content for ${event.location}!`
})

Preventing the event will not prevent the browser from restoring the URL in the address bar.

Important

Custom restoration code should avoid pushing new history entries.

Properties

event.location string

The URL for the restored history entry.

event.preventDefault()

Prevent Unpoly from restoring content for this history entry.

Preventing the event will not prevent the browser from restoring the URL in the address bar.