This module encapsulates access to the page URL’s fragment part, i.e. the part after a hash (#) symbol.
The following methods are provided by this module:
$p.url.fragment.get()
Returns the current URL fragment as String, or an empty string if none exists.
$p.url.fragment.set(name)
Sets a new fragment to be shown in the address bar of the browser. This will also trigger any callbacks that are attached, e.g. via the .onChange() method.
$p.url.fragment.onChange(callback)
This method allows to attach a callback function that will be called when the URL fragment of the page changes.
Example:
$p.url.fragment.onChange( (e) => { console.log($p.url.fragment.get()); e.preventDefault(); });
.preventDefault() method if you want to avoid the URL change to trigger default browser functionalities.