After a call to navigateTo,
- currentPagereflects the new page,
- The browser location and navigation history are updated accordingly,
- The window scroll position is set to “top”.
Please note that the changes may be applied asynchronously.
Params
- target(- Function,- Link,- Obj,- DataItem) – The page or resource to be opened. This can be a callback function returning an- Obj, a- Link, or a- DataItem.
- [New in 1.50.0] target(String) – URL to navigate to. The URL needs to be a full URL, i.e., start with “https://”.
- options(Object) – Supports setting the hash and the query parameters of the browser location. The options are ignored if- targetis an external- Link.- hash(String) – The browser location hash
- params(Object) – The browser location query parameters
 
Throws
- ArgumentErrorif the- targetparameter is invalid or missing.
Remarks
- If the target is an external link, Scrivito doesn’t change the currentPageand the window scroll position.
- If the target is a Link, thehashandqueryof the link are used asnavigateTooptions.
- If the target is a DataItem, a link for navigating to the item’s details page is created. If thequeryprovided toScrivito.navigateTomatches that of the details page, an error is raised.
- If you call navigateTomultiple times, the last call (in the order in which they were made) wins.
- Scrivito loads data asynchronously from the CMS backend. To make sure your targetobject data is available for navigation, pass intargetas a function.
- For convenience, navigateTooffers a shortcut for providing query parameters: unknown keys in theoptionsobject are interpreted as query parameters.
- A callback function will always work:Scrivito.navigateTo(() => Scrivito.Obj.getByPath("/company/about-us"));
 This fails if “About Us” has not yet been loaded in the current page context:Scrivito.navigateTo(Scrivito.Obj.getByPath("/company/about-us"));