rak*_*los 24 javascript url absolute-path
在javascript中,如何获取当前网址的相对路径?
例如 http://www.example.com/test/this?page=2
http://www.example.com/test/this?page=2
我只想要 /test/this?page=2
/test/this?page=2
Dr.*_*lle 53
尝试
window.location.pathname+window.location.search
Ber*_*ann 5
location.href
保存您的脚本正在运行的页面的 url。
Joe*_*son 5
最快最全的方法:
location.href.replace(/(.+\w\/)(.+)/,"/$2");
归档时间:
15 年,4 月 前
查看次数:
62568 次
最近记录:
8 年,9 月 前