midoriHistory
With midoriHistory, you can mark the different states of a page, and users can navigate through these states by using the back and forward buttons without having to reload the page. midoriHistory is ideal for Ajax applications, but it can also be used by any web application that changes the contents of the page and wants to keep the back/forward navigation working.
Each state is stored in the URL of the page by simply appending a pound sign (#) and the state name to the URL. In this way, users can bookmark each state and come back to them later as long as your web application supports recreating states.
-
init(callback)Initializes the history module.
callback is the callback function that will be called when the user uses the back or forward buttons. The current history position will be passed to this function.
Example:
midori.addEventListener(window, 'ready', function (e) { midoriHistory.init(function (pos) { alert('Current history position:' + pos); } ); } ); -
add(item)Adds an history entry and changes the URL of the page accordingly.
item is the history entry that will be added to the end of the history.
Since each history entry is stored in the URL as an internal anchor (#item), you must make sure that your history entries do not match any element id on the page.
Example:
var i = 0; [Run] <a href="javascript: midoriHistory.add('state' + ++i)">Run</a>
-
remove(item)Removes a history entry.
item is the name of the history entry.
Example:midoriHistory('state1');
