API reference up.history
module

Features to update the browser history and handle the Back button.

up.history.location is the current URL as Unpoly sees it, and up:location:changed is emitted whenever it changes, for example to track page views. When the user goes back, up:location:restore is emitted before Unpoly fetches the restored URL and renders it; listeners can prevent this to handle restoration themselves. An [up-back] link points to the previous URL. To change history from your own code, call up.history.push() or up.history.replace().


Features

  • [up-back] ATTR

    Changes the link's destination so it points to the previous URL.

  • Configures behavior when the user goes back or forward in browser history.

  • Returns whether the given URL matches the current browser location.

  • Returns a normalized URL for the current browser location.

  • Returns a normalized URL for the previous history entry.

  • up.history.push(url) JS experimental

    Adds a new history entry and updates the browser's address bar.

  • up.history.replace(url) JS experimental

    Replaces the current history entry and updates the browser's location bar.

  • up.history.url() JS deprecated

    Returns a normalized URL for the current history entry.

  • This event is emitted after the browser's address bar has been updated with a new URL.

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

  • [up-meta] ATTR

    Configures whether this <head> element is updated during history changes.