onChange( )
Adds an event handler that runs when an application page's URL changes.
Description
The event handler set by the onChange()
function runs when the location is changed
but the change doesn't trigger navigation. This situation occurs when navigating between
subitems on a page that is managed by a full-page application.
For example, a store product page is a full-page application. When a product page's path
changes because it is switching between items, no actual navigation is taking place. You
can use the onChange()
event handler to determine when a new product is displayed and
perform any necessary partial updates on the current page.
The onChange()
function can only be used when browser
rendering happens,
meaning you can only use it in frontend code after the page is ready.
To determine if a page is managed by a full-page application, use the wix-site
currentPage
property or getSiteStructure()
function to retrieve a StructurePage
object that
corresponds to the page. If the object contains an applicationId
value, then the
page is managed by a full-page application.
Authorization
Request
This endpoint does not take any parameters
Status/Error Codes
Was this helpful?
Get the new location path
1import wixLocation from 'wix-location';23// ...45wixLocation.onChange( (location) => {6 let newPath = location.path;7} );