- Source:
Methods
changeCurrentUrl(urlopt, usePushStateopt, nullable, stateopt, nullable, titleopt, nullable)
Changes the current URL by using the history API (this means, we can only change to a path on the same origin). Be aware that this replaces the current URL in the history without any normal navigation or reload. This method only works if the history API is supported by the browser, otherwise no navigation will occur (but a warning will be shown in console). For more details on the history API see: https://developer.mozilla.org/en-US/docs/Web/API/History
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url |
String | URL |
<optional> |
null | a url to change the current address to on the same origin, will use current URL if nullish |
usePushState |
Boolean |
<optional> <nullable> |
false | push new state instead of replacing current |
state |
* |
<optional> <nullable> |
null | a serializable object to append to the history state (gets retrieved on popState-event) |
title |
String |
<optional> <nullable> |
null | a name/title for the new state (as of yet, only Safari uses this, other browser will return undefined) |
- Source:
- See:
-
- onHistoryChange
- Urls.urlHref
Throws:
error if state is not serializable by browser
Example
changeCurrentUrl('/article/important-stuff', false, {id : 666});