【发布时间】:2016-06-19 03:01:08
【问题描述】:
我试图在域之后提取 url。根据这个question,可以通过调用window.location.pathname,但在我的网址http://domain:host/something#random=123 中,它会删除# 之后的所有内容。还有什么比拆分或正则表达式更好的吗?
在代码中:
window.location.pathname("http://domain:host/something#random=123")
返回/something
期望的行为:
window.location.unknownMethodToMe("http://domain:host/something#random=123")
应该返回/something#random=123
提前致谢。
【问题讨论】:
标签: javascript