/** * Returns the hash portion of the location URL (the portion following the '#'). * @return the hash portion of the location URL * @see <a href="http://msdn.microsoft.com/en-us/library/ms533775.aspx">MSDN Documentation</a> */ @JsxGetter public String getHash() { final boolean decodeHash = getBrowserVersion().hasFeature(JS_LOCATION_HASH_IS_DECODED); String hash = hash_; if (hash_ != null && (decodeHash || hash_.equals(getUrl().getRef()))) { hash = decodeHash(hash); } if (StringUtils.isEmpty(hash)) { if (getBrowserVersion().hasFeature(JS_LOCATION_HASH_RETURNS_HASH_FOR_EMPTY_DEFINED) && getHref().endsWith("#")) { return "#"; } } else if (getBrowserVersion().hasFeature(JS_LOCATION_HASH_HASH_IS_ENCODED)) { return "#" + UrlUtils.encodeHash(hash); } else { return "#" + hash; } return ""; }
/** * Returns the hash portion of the location URL (the portion following the '#'). * @return the hash portion of the location URL * @see <a href="http://msdn.microsoft.com/en-us/library/ms533775.aspx">MSDN Documentation</a> */ @JsxGetter public String getHash() { final boolean decodeHash = getBrowserVersion().hasFeature(JS_LOCATION_HASH_IS_DECODED); String hash = hash_; if (hash_ != null && (decodeHash || hash_.equals(getUrl().getRef()))) { hash = decodeHash(hash); } if (StringUtils.isEmpty(hash)) { if (getBrowserVersion().hasFeature(JS_LOCATION_HASH_RETURNS_HASH_FOR_EMPTY_DEFINED) && getHref().endsWith("#")) { return "#"; } } else if (getBrowserVersion().hasFeature(JS_LOCATION_HASH_HASH_IS_ENCODED)) { return "#" + UrlUtils.encodeHash(hash); } else { return "#" + hash; } return ""; }