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).
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
AP.require(["history"], function(history){ history.back(); // go back by 1 entry in the browser history. }); -
forward() -
Goes back one step in the joint session history. Will invoke the popstate callback
Example
AP.require(["history"], function(history){ history.forward(); // go forward by 1 entry in the browser history. }); -
getState() -
The current url anchor.
Returns:
String
Example
AP.require(["history"], function(history){ history.pushState("page5"); history.getState(); // returns "page5"; }); -
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 intdelta
Example
AP.require(["history"], function(history){ history.go(-2); // go back by 2 entries in the browser history. }); -
popState(Function) -
Register a function to be executed on state change
Parameters:
Name Type Description Functioncallback 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 Stringurl to add to history
-
replaceState(String) -
Updates the current entry in the session history. Does NOT invoke popState callback
Parameters:
Name Type Description Stringurl to add to history