Top Hash Change
The addTopHashChangeEventListener
method helps to navigate in Suite from iframes by letting an app in an iframe be notified of hashchange
events on top window. With its pair, the removeTopHashChangeEventListener
, the subscription can be cancelled.
A sample workflow is that the app gets the current top url with e.utils.getTopUrl()
and uses the hash/fragment for it's initial routing, then on any top hash change it updates it's current state. All links should use target="_top"
attribute (or a <base>
tag should be used for the same result). By that, the app can be opened in current tab or in a new tab or page, and won't lose it's current route on refresh.
window.e.utils.addTopHashChangeEventListener(({ oldURL, newURL }) => console.log({ oldURL, newURL }));
Top hash change utility methods
Method
Name | Description |
---|---|
e.utils.addTopHashChangeEventListener(callback: (data: { oldURL: string, newURL: string }) => void) |
Registers a callback function that will be called on each hashchange event on top window. |
e.utils.removeTopHashChangeEventListener(callback) |
The given callback won't be called anymore on hash changes. |