History API Changing the URL of the host product, allowing manipulation of the browser history. Note: This is only enabled for page modules (Admin page, General page, Configure page, User profile page). It cannot be used if the page module is launched as a dialog.
Example
AP.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(); });
Methods
back
()Goes back one step in the joint session history. Will invoke the popstate callback
Example
forward
()Goes back one step in the joint session history. Will invoke the popstate callback
Example
getState
()The current url anchor.
Returns:
String
Example
go
(int)Goes back or forward the specified number of steps A zero delta will reload the current page. If the delta is out of range, does nothing. Will invoke the popstate callback
Parameters:
Name Type Description int
delta
Example
popState
(Function)Register a function to be executed on state change
Parameters:
Name Type Description Function
callback to be executed on state change.
pushState
(String)Pushes the given data onto the session history. Does NOT invoke popState callback
Parameters:
Name Type Description String
url to add to history
replaceState
(String)Updates the current entry in the session history. Does NOT invoke popState callback
Parameters:
Name Type Description String
url to add to history