我得到的location.href是这样的:
http://stackoverflow.com/questions/ask
Run Code Online (Sandbox Code Playgroud)
但我只想得到questions/ask(/第一个角色没有)
怎么做到这一点?
Fel*_*ing 13
该location对象具有pathname属性.
这将为您提供/questions/ask并删除第一个字符,使用substring(1):
var path = location.pathname.substring(1);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40788 次 |
| 最近记录: |