【发布时间】:2014-10-05 12:09:46
【问题描述】:
【问题讨论】:
-
window.location.pathname -
@RGraham 我想要 / 之后的路径名
-
只需将其从字符串中删除即可。 (.substr(1);)
-
@Fataoulas 你真的试着找到自己吗?
标签: javascript
【问题讨论】:
window.location.pathname
标签: javascript
你可以使用
window.location.pathname.substring(1)
【讨论】:
/ 不是域的一部分,它是路径的一部分。
你会使用window.location.pathname
console.log(window.location.pathname.substring(1));
这将输出第一个 / 之后的所有内容
【讨论】: