The history
API allows your app to manipulate the current page URL for use in navigation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16AP.require(["history"], function(history){ // Register a function to run when state is changed. // You should use this to update your UI to show the state. history.popState(function(e){ alert("The URL has changed from: " + e.oldURL + "to: " + e.newURL); }); // Adds a new entry to the history and changes the url in the browser. history.pushState("page2"); // Changes the URL back and invokes any registered popState callbacks. history.back(); });
Goes back one step in the joint session history. Will invoke the popstate callback.
1 2AP.require(["history"], function(history){ history.back(); // go back by 1 entry in the browser history. });
Goes back one step in the joint session history. Will invoke the popstate callback.
1 2AP.require(["history"], function(history){ history.forward(); // go forward by 1 entry in the browser history. });
The current URL anchor.
Returns: String
1 2AP.require(["history"], function(history){ history.pushState("page5"); history.getState(); // returns "page5"; });
Goes back or forward the specified number of steps. A zero delta will reload the current page. If the delta is out of range, it does nothing. Will invoke the popstate callback.
Name | Type | Description |
---|---|---|
int | delta |
1 2AP.require(["history"], function(history){ history.go(-2); // go back by 2 entries in the browser history. });
Register a function to be executed on state change.
Name | Type | Description |
---|---|---|
Function | callback to be executed on state change |
Pushes the given data onto the session history. Does NOT invoke popState
callback.
Name | Type | Description |
---|---|---|
String | URL to add to history |
Updates the current entry in the session history. Does NOT invoke popState
callback.
Name | Type | Description |
---|---|---|
String | URL to add to history |
Rate this page: