我有:
var uri = window.location.href;
Run Code Online (Sandbox Code Playgroud)
这提供了 http://example.com/something#hash
什么是最好和最简单的方法来获得没有的整个路径#hash
?
uri = http://example.com/something#hash
nohash = http://example.com/something
Run Code Online (Sandbox Code Playgroud)
我尝试使用location.origin+location.pathname
哪个在每个浏览器中都不起作用.我尝试使用location.protocol+'//'+location.host+location.pathname
这对我来说看起来像一个糟糕的解决方案.
最好和最简单的方法是什么?也许我查询location.hash并尝试从uri中substr()这个?