Provides browser history management backed by
window.location.hash
, as well as convenience methods for working
with the location hash and a synthetic hashchange
event that
normalizes differences across browsers.
_updateIframe
hash
replace
Updates the history iframe with the specified hash.
createHash
params
Creates a location hash string from the specified object of key/value pairs.
params
Object
object of key/value parameter pairs
location hash string
decode
string
Wrapper around decodeURIComponent()
that also converts +
chars into spaces.
string
String
string to decode
decoded string
encode
string
Wrapper around encodeURIComponent()
that converts spaces to
string
String
string to encode
encoded string
getHash
Gets the raw (not decoded) current location hash, minus the preceding '#' character and the hashPrefix (if one is set).
current location hash
getIframeHash
Gets the raw (not decoded) current location hash from the IE iframe, minus the preceding '#' character and the hashPrefix (if one is set).
current iframe hash
getUrl
Gets the current bookmarkable URL.
current bookmarkable URL
parseHash
hash
Parses a location hash string into an object of key/value parameter pairs. If hash is not specified, the current location hash will be used.
hash
String
(optional) location hash string
object of parsed key/value parameter pairs
replaceHash
hash
Replaces the browser's current location hash with the specified hash
and removes all forward navigation states, without creating a new browser
history entry. Automatically prepends the hashPrefix
if one
is set.
hash
String
new location hash
setHash
hash
Sets the browser's location hash to the specified string. Automatically
prepends the hashPrefix
if one is set.
hash
String
new location hash
_REGEX_HASH
Regular expression used to parse location hash/query strings.
hashPrefix
Prefix to prepend when setting the hash fragment. For example, if the
prefix is !
and the hash fragment is set to
#foo=bar&baz=quux
, the final hash fragment in the URL will
become #!foo=bar&baz=quux
. This can be used to help make an
Ajax application crawlable in accordance with Google's guidelines at
http://code.google.com/web/ajaxcrawling/.
Note that this prefix applies to all HistoryHash instances. It's not possible for individual instances to use their own prefixes since they all operate on the same URL.
Default: ''
SRC_HASH
Constant used to identify state changes originating from
hashchange
events.