我有:
var uri = window.location.href;
这提供了http://example.com/something#hash
如何最好最简单地获取没有#hash
的整个路径?
uri = http://example.com/something#hash
nohash = http://example.com/something
我尝试使用location.origin+location.pathname
,但它并不适用于所有浏览器。我也尝试了location.protocol+'//'+location.host+location.pathname
,但这种方法看起来有点糟糕。
有没有更好、更简单的方法呢?也许我可以查询location.hash
并从URI中截取它?