相关疑难解决方法(0)

javascript窗口位置href没有哈希?

我有:

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()这个?

javascript location substring

72
推荐指数
5
解决办法
7万
查看次数

标签 统计

javascript ×1

location ×1

substring ×1