开发者

What's the best way to check for the presence of a hash?

Right now I'm using

if(window.locatio开发者_开发问答n.hash != '')

Is this foolproof? Or, is there a way to return a Boolean value instead?


window.location.hash will return empty string if the hash symbol is present in the URL but it doesn't have anything on it's right side. If there's a value it will return the value with the hash symbol as first character. This might be a bit confusing in certain situations.

Part from that I'd say it's a pretty solid way of using it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜