dojo/back

Summary

Browser history management resources

See the dojo/back reference documentation for more information.

Methods

addToHistory(args)

Defined by dojo/back

adds a state object (args) to the history list.

To support getting back button notifications, the object argument should implement a function called either "back", "backButton", or "handle". The string "back" will be passed as the first and only argument to this callback.

To support getting forward button notifications, the object argument should implement a function called either "forward", "forwardButton", or "handle". The string "forward" will be passed as the first and only argument to this callback.

If you want the browser location string to change, define "changeUrl" on the object. If the value of "changeUrl" is true, then a unique number will be appended to the URL as a fragment identifier (http://some.domain.com/path#uniquenumber). If it is any other value that does not evaluate to false, that value will be used as the fragment identifier. For example, if changeUrl: 'page1', then the URL will look like: http://some.domain.com/path#page1

There are problems with using dojo/back with semantically-named fragment identifiers ("hash values" on an URL). In most browsers it will be hard for dojo/back to know distinguish a back from a forward event in those cases. For back/forward support to work best, the fragment ID should always be a unique value (something using new Date().getTime() for example). If you want to detect hash changes using semantic fragment IDs, then consider using dojo/hash instead (in Dojo 1.4+).

Parameter Type Description
args Object

The state object that will be added to the history list.

Examples

Example 1

back.addToHistory({
    back: function(){ console.log('back pressed'); },
    forward: function(){ console.log('forward pressed'); },
    changeUrl: true
});

getHash()

Defined by dojo/back

Returns: undefined

goBack()

Defined by dojo/back

private method. Do not call this directly.

goForward()

Defined by dojo/back

private method. Do not call this directly.

init()

Defined by dojo/back

Initializes the undo stack. This must be called from a

© 2005–2017 JS Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.
http://dojotoolkit.org/api/1.10/dojo/back.html