【发布时间】:2018-04-27 10:16:58
【问题描述】:
我想检查 url 中是否有哈希:
这应该返回 true:
domain.com/balbla#hash
这应该返回 false:
domain.com/balbla
所以我使用URI.js 来获取哈希
var uriFragment = new URI(window.location.href).fragment();
if (uriFragment.length) {
console.log('yep')
} else {
console.log('nope')
}
但这永远不会返回 nope,即使 url 中没有哈希。
【问题讨论】:
标签: javascript jquery uri uri.js