W3cubDocs

/Dojo

dojo/hash

Summary

Gets or sets the hash string in the browser URL.

Handles getting and setting of location.hash.

  • If no arguments are passed, acts as a getter.
  • If a string is passed, acts as a setter.

Usage

hash(hash,replace);
Parameter Type Description
hash String
Optional

the hash is set - #string.

replace Boolean
Optional

If true, updates the hash value in the current history state instead of creating a new history state.

Returns: any | undefined

when used as a getter, returns the current hash string. when used as a setter, returns the new hash string.

See the dojo/hash reference documentation for more information.

Examples

Example 1

topic.subscribe("/dojo/hashchange", context, callback);

function callback (hashValue){
    // do something based on the hash value.
}

Methods

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