HistoryHash Class
yui3/src/history/js/history-hash.js:1
Parent Module: history
Available since 3.2.0
Provides browser history management backed by <code>window.location.hash</code>, as well as convenience methods for working with the location hash and a synthetic <code>hashchange</code> event that normalizes differences across browsers.
Index
Methods
- _afterHashChange
- _updateIframe static
- createHash static
- decode static
- encode static
- getHash static
- getIframeHash static
- getUrl static
- parseHash static
- replaceHash static
- setHash static
Properties
- _REGEX_HASH static
- hashPrefix static
- SRC_HASH static
Methods
_updateIframe
-
hash
-
replace
Updates the history iframe with the specified hash.
Parameters:
-
hash
Stringlocation hash
-
replace
Boolean(optional) if <code>true</code>, the current history state will be replaced without adding a new history entry
createHash
-
params
Creates a location hash string from the specified object of key/value pairs.
Parameters:
-
params
Objectobject of key/value parameter pairs
Returns:
location hash string
decode
-
string
Wrapper around <code>decodeURIComponent()</code> that also converts + chars into spaces.
Parameters:
-
string
Stringstring to decode
Returns:
decoded string
encode
-
string
Wrapper around <code>encodeURIComponent()</code> that converts spaces to
- chars.
Parameters:
-
string
Stringstring to encode
Returns:
encoded string
getHash
()
String
static
Gets the raw (not decoded) current location hash, minus the preceding '#' character and the hashPrefix (if one is set).
Returns:
current location hash
getIframeHash
()
String
static
Gets the raw (not decoded) current location hash from the IE iframe, minus the preceding '#' character and the hashPrefix (if one is set).
Returns:
current iframe hash
getUrl
()
String
static
Gets the current bookmarkable URL.
Returns:
current bookmarkable URL
parseHash
-
hash
Parses a location hash string into an object of key/value parameter pairs. If <i>hash</i> is not specified, the current location hash will be used.
Parameters:
-
hash
String(optional) location hash string
Returns:
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 <code>hashPrefix</code> if one is set.
Parameters:
-
hash
Stringnew location hash
setHash
-
hash
Sets the browser's location hash to the specified string. Automatically prepends the <code>hashPrefix</code> if one is set.
Parameters:
-
hash
Stringnew location hash
Properties
_REGEX_HASH
RegExp
protected
final
static
Regular expression used to parse location hash/query strings.
hashPrefix
String
static
<p> Prefix to prepend when setting the hash fragment. For example, if the prefix is <code>!</code> and the hash fragment is set to <code>#foo=bar&baz=quux</code>, the final hash fragment in the URL will become <code>#!foo=bar&baz=quux</code>. This can be used to help make an Ajax application crawlable in accordance with Google's guidelines at <a href="http://code.google.com/web/ajaxcrawling/">http://code.google.com/web/ajaxcrawling/</a>. </p>
<p> 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. </p>
Default: ''
SRC_HASH
String
final
static
Constant used to identify state changes originating from <code>hashchange</code> events.